2013-03-07 116 views
0

我剛更改了我的應用程序,我很困惑。它從根視圖開始,然後推入第二個視圖,在該視圖上有一個按鈕,推動另一個視圖... 因此,我決定改爲展示第二個視圖控制器,但現在另一個視圖不能從第二個視圖推動。在呈現第一個視圖後導航視圖控制器

代碼從根查看:

//This works 
[[self navigationController] presentViewController:secondViewController 
              animated:YES completion:nil]; 

代碼從第二個視圖:

//This Does not work 
[[self navigationController] pushViewController:locactionView animated:YES]; 

編輯:對不起缺乏細節。不會拋出異常,只是不會推送「位置視圖」。在我介紹視圖之前,我推動了它,一切正常。此外,當最初推送視圖時導航欄是可見的,現在View Controller已呈現,我無法推送視圖或查看導航欄。我希望這有幫助。我不知道我可以添加什麼代碼,因爲在問題發生之前我只更改了一行代碼。

+0

什麼不行?它不會推視圖控制器?它會崩潰嗎? – 2013-03-07 15:28:54

+0

你能分享更多的代碼嗎? – Anupdas 2013-03-07 15:30:22

回答

0

在AppDelegate中,你可以與RootViewController的第一初始化NavigationController,然後你可以推棧上的viewControllers,如果您有層次設立這樣,可以解決你的問題

YourNavigationController *yourNavigationController = [[YourNavigationController alloc] initWithRootViewController:self.firstViewController]; 
+0

我已經有一個初始化,但謝謝你嘗試。 – Tanner 2013-03-07 15:32:15

+0

那麼看到更多的代碼可能是個好主意 – nsgulliver 2013-03-07 15:33:31

0

self.rootViewController = [[RootViewController alloc] initWithNibName:@"RootViewController" 
                   bundle:nil]; 
self.navigationController = [[UINavigationController alloc] initWithRootViewController:self.rootViewController]; 
self.window.rootViewController = self.navigationController; 
[self.window makeKeyAndVisible]; 

你不應該對這個東西有任何問題。你的問題可能是你試圖從你提供的模式化的視圖控制器上推到導航控制器上,你不能這麼做

+0

我不明白什麼rootViewController是在這個 – Tanner 2013-03-09 18:18:43

相關問題