2011-02-28 55 views
2

我的編碼是什麼是錯誤「應用程序試圖推動一個無視圖控制器的目標<UINavigationController:0x498efa0>。」?

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { 

FirstTabBarItem = [[FirstMuseum alloc] init]; 
SecondTabBarItem = [[SecondMaps alloc] init]; 
ThirdTabBarItem = [[ThirdExhibition alloc] init]; 
FourthTabBarItem = [[FourthTabBarItem alloc] init]; 


first = [[UINavigationController alloc] initWithRootViewController:FirstTabBarItem]; 
second = [[UINavigationController alloc] initWithRootViewController:SecondTabBarItem]; 
third = [[UINavigationController alloc] initWithRootViewController:ThirdTabBarItem]; 
fourth = [[UINavigationController alloc] initWithRootViewController:FourthTabBarItem]; 


first.title = @"Hello"; 
second.title = @"Hello"; 
third.title = @"Hello"; 
fourth.title = @"Hello"; 

myControllerArray = [[NSMutableArray alloc] init]; 

[myControllerArray addObject:first]; 
[myControllerArray addObject:second]; 
[myControllerArray addObject:third]; 
[myControllerArray addObject:fourth]; 


myTabBar = [[UITabBarController alloc] init]; 

[myTabBar setViewControllers:myControllerArray]; 

localNavigationController = [[UINavigationController alloc] initWithRootViewController:myTabBar]; 

NSLog(@"Hello, You Tapped !"); } 

是什麼錯誤, 我試圖做一個的UITabBarController有四個項目,所以現在我該怎麼辦 ??????

回答

4

這意味着試圖推送的視圖控制器沒有正確分配。請檢查連接視圖控制器的配置,看看它乾淨利落地分配

+0

@ 2KV7,我給出了編碼,並且我初始化了所有四個對象,那麼爲什麼這個錯誤是? – 2011-02-28 11:27:01

+0

我發現了這個錯誤,它在初始化的時候從我身上弄得一團糟,沒有別的......,thanx – 2011-02-28 11:30:59

+0

Gr8。很高興你發現錯誤。快樂編碼 – visakh7 2011-02-28 11:38:41

-1

是你可以忘記分配視圖控制器,以便盡我的代碼:

1)tapaction指按鈕動作

_forgotviewcontroller means my second view property eg: 

@property (nonatomic,strong) ForgotPassword *forgotviewController; 

中聲明我的firstView

-(void) tapAction:(id)sender 
{ 
    _forgotviewController=[[ForgotPassword alloc]init]; 
    [self.navigationController pushViewController:self.forgotviewController animated:YES]; 
} 

試試這個,你港島線得到導航

相關問題