2013-08-31 40 views
1

我有一個UIViewController,我想從這個視圖導航到我的第二個視圖控制器pushViewController不起作用

SecondView *secondView=[[SecondView alloc] initWithNibName:@"SecondView" bundle:nil]; 
[self.navigationController pushViewController:secondView animated:YES]; 
[secondView release]; 

它不工作。它什麼都不做,也沒有錯誤。我錯過了什麼?

SOLUTION

在AppDelegate中的文件我已經添加了navigationcontroller。

UINavigationController *navCtrlr = [[UINavigationController alloc]initWithRootViewController:self.viewController]; 
[self.window setRootViewController:navCtrlr]; 
navCtrlr.delegate = self; 
navCtrlr.navigationBarHidden = YES; 
+1

self.navigationController爲零,或者secondView爲零,或者secondView不是視圖控制器。 –

回答

1

您的視圖控制器已經在導航控制器內,否則它不會工作。將NSLog放在self.navigationcontroller上,看看它在打印什麼

+0

謝謝..我發現我的錯誤是... – onivi

相關問題