2012-05-18 34 views
0

在視圖之間傳遞數據好的,所以我有我的應用程序的一部分,我正在處理視圖之間傳遞浮動變量,一切都很好,但所有的按鈕看起來有點混亂。並正在讓我差不多完成我想看看我是否可以添加tabBar到現有的視圖和清理它。我發現了一個很好的教程,並且將它鏈接起來並報告了我在NSLog中選擇的選項卡,然後繼續粘貼我用於相同功能的按鈕的代碼。一切都變得有點滑稽,我不得不做出一些新的變數,並且我陷入了我無法弄清楚的最後一個錯誤。 它呼籲預期的表現,第一次我打電話patternRafter使用tabBar

- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item { 
NSLog(@"didSelectItem: %d", item.tag); 

[self activateTab:item.tag]; 
} 

- (void)activateTab:(int)index { 
switch (index) { 
    case 1: 

     patternRafter *patternRafter1 = [[patternRafter alloc]initWithNibName:nil bundle:nil]; 

     BuildNavAppDelegate *buildNavDelegate = (BuildNavAppDelegate *)[[UIApplication sharedApplication]delegate]; 

     buildNavDelegate.TLPMR = [TLMR text]; 
     buildNavDelegate.comRaftBirdPassed = [comBird text]; 
     buildNavDelegate.comRaftLengthPassed = [comRafter text]; 
     buildNavDelegate.raftThicknessPassed = [rafterWidth text]; 



     [self presentModalViewController:patternRafter1 animated:YES]; 
     break; 
    /*case 2: 

     buildersSquare *square1 = [[buildersSquare alloc]initWithNibName:nil bundle:nil]; 

     BuildNavAppDelegate *buildNavDelegate = (BuildNavAppDelegate *)[[UIApplication sharedApplication]delegate]; 

     buildNavDelegate.TLPMR = [TLMR text]; 
     buildNavDelegate.comRaftBirdPassed = [comBird text]; 
     buildNavDelegate.comRaftLengthPassed = [comRafter text]; 
     buildNavDelegate.raftThicknessPassed = [rafterWidth text]; 



     [self presentModalViewController:square1 animated:YES];   
     break; 
    case 3: 

     self.tab2ViewController =[[tab2 alloc] initWithNibName:@"tab2" bundle:nil]; 
     [self.view insertSubview:tab2ViewController.view belowSubview:tabbar1]; 
     if (currentViewController != nil) 
      [currentViewController.view removeFromSuperview]; 
     currentViewController = tab2ViewController;   
     break;*/ 
    default: 
     break; 
} 

}

任何幫助,將不勝感激。謝謝 我剛剛意識到我無法發佈圖片,因爲我仍然是一個新用戶。所以這裏是一個鏈接,如果有人想檢查出來。 http://dl.dropbox.com/u/72193343/Screen%20shot%202012-05-18%20at%209.22.48%20AM.png

+0

對不起,我已經在其他職位剛剛看到這個,現在我知道如何,三江源。 –

+0

不用擔心。這個答案對你有用嗎? – geraldWilliam

+0

沒有答案沒有工作。但我現在明白他的意思。這是我第一次嘗試一個應用程序,並且開始時相當sl,,所以爲了保持它的正常運行,爲了這個我繼續使用這些不良習慣。然而,我在其他地方找到了解決問題的一些幫助,但仍然給我留下了一些警告。由於我仍然是新用戶,因此我無法回答自己的問題2個小時。 –

回答

0

我想象patternRafter是一個名爲PatternRafter的類的實例嗎?如果是這樣,該行需要看起來像這樣:

PatternRafter *patternRafter1 = [[PatternRafter alloc] initWithNibName:nil bundle:nil]; 

的OBJ-C是區分大小寫和命名約定要求的ivars以較低的情況下,並開始上課開始與首都。

0
- (void)activateTab:(int)index { 
switch (index) { 
case 1://igot it to work by opening brackets here{ 

    patternRafter *patternRafter1 = [[patternRafter alloc]initWithNibName:nil bundle:nil]; 

    BuildNavAppDelegate *buildNavDelegate = (BuildNavAppDelegate *)[[UIApplication sharedApplication]delegate]; 

    buildNavDelegate.TLPMR = [TLMR text]; 
    buildNavDelegate.comRaftBirdPassed = [comBird text]; 
    buildNavDelegate.comRaftLengthPassed = [comRafter text]; 
    buildNavDelegate.raftThicknessPassed = [rafterWidth text]; 



    [self presentModalViewController:patternRafter1 animated:YES]; //local declaration of 'patternRafter1' hides instance variable 
    break;//and closing here} 
case 2: 

其工作正常,但我收到的警告 - 「patternRafter1」的局部聲明隱藏實例變量