2013-01-31 50 views
0

我有一個調用應用程序的LocalNotification。如何將ViewController從AppDelegate添加到現有的NavigationController?

在應用程序中,幾乎所有視圖都與NavigationController連接,以顯示標題欄和「全局菜單」。

當應用程序被從通知的動作被調用,AppDelegate中必須調用包含「全局菜單」網頁視圖。這意味着,我必須將這個「WebView」添加到應用程序的NavigationController中。

首先,我想是這樣的:(在AppDelegate中)

UIViewController *currentVc = self.window.rootViewController; 
[currentVc.navigationController pushViewController:orderVc animated:NO]; 

但它不會顯示任何內容。所以,我已經試過這樣:

UIViewController *currentVc = self.window.rootViewController; 
[currentVc presentViewController:orderVc animated:NO completion:nil]; 

隨後的WebView(currentVc)顯示器,但它不是整個應用程序的導航控制之下,所以沒有「全局菜單」。

我已經檢查如果UIViewController中(self.window.rootViewController)是零,但事實並非如此。

我周圍搜索,發現很多類似的問題,但他們都與我的情況相反。

有沒有簡單的方法可以將ViewController添加到NavigationController以顯示「標題欄」?抱歉太模糊的問題,但我真的需要再次幫助。

在此先感謝。

+0

您是否從nib文件添加navigationController? –

+0

是的。我正在使用storyboard來創建navigationController。當實例化WebViewController時,我使用WebViewController * orderVc = [self.window.rootViewController.storyboard instantiateViewControllerWithIdentifier:@「webviewcontroller」];在大多數情況下,使用pushViewController就可以。但是,從AppDelegate,雖然我可以使用presentViewController(這似乎表明self.window.rootViewController不是零),推送將無法正常工作。 –

回答

0

每個視圖控制器都控制其自己的navigationItem。如果您想要顯示您推送的VC的按鈕/標題,則必須更新導航項目。通常viewWillAppear是一個好地方。

+0

感謝您的建議。但我只是想添加一個viewcontroller到現有的navigationController層次結構。對不起我的英文,解釋這個問題有點難... –

相關問題