我有一個調用應用程序的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以顯示「標題欄」?抱歉太模糊的問題,但我真的需要再次幫助。
在此先感謝。
您是否從nib文件添加navigationController? –
是的。我正在使用storyboard來創建navigationController。當實例化WebViewController時,我使用WebViewController * orderVc = [self.window.rootViewController.storyboard instantiateViewControllerWithIdentifier:@「webviewcontroller」];在大多數情況下,使用pushViewController就可以。但是,從AppDelegate,雖然我可以使用presentViewController(這似乎表明self.window.rootViewController不是零),推送將無法正常工作。 –