Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何从AppDelegate将ViewController添加到现有NavigationController?_Ios_Objective C_Viewcontroller_Navigationcontroller - Fatal编程技术网

Ios 如何从AppDelegate将ViewController添加到现有NavigationController?

Ios 如何从AppDelegate将ViewController添加到现有NavigationController?,ios,objective-c,viewcontroller,navigationcontroller,Ios,Objective C,Viewcontroller,Navigationcontroller,我有一个调用应用程序的LocalNotification 在应用程序中,几乎所有视图都与NavigationController连接,以显示标题栏和“全局菜单” 当通知中的操作调用应用程序时,AppDelegate必须调用包含“全局菜单”的WebView。这意味着,我必须将这个“WebView”添加到应用程序的NavigationController中 首先,我尝试了以下方法:(在AppDelegate中) 但它不会显示任何内容。所以我试过这样做: UIViewController *curre

我有一个调用应用程序的LocalNotification

在应用程序中,几乎所有视图都与NavigationController连接,以显示标题栏和“全局菜单”

当通知中的操作调用应用程序时,AppDelegate必须调用包含“全局菜单”的WebView。这意味着,我必须将这个“WebView”添加到应用程序的NavigationController中

首先,我尝试了以下方法:(在AppDelegate中)

但它不会显示任何内容。所以我试过这样做:

UIViewController *currentVc = self.window.rootViewController;
[currentVc presentViewController:orderVc animated:NO completion:nil];  
然后显示WebView(currentVc),但它不在整个应用程序的导航控制器下,因此没有“全局菜单”

我已经检查了UIViewController(self.window.rootViewController)是否为nil,但不是

我四处搜索,发现了许多类似的问题,但它们都与我的情况相反

有没有简单的方法将ViewController添加到NavigationController以显示“标题栏”?对不起,这个问题太模糊了,但我真的需要再次帮助


提前感谢。

每个视图控制器都可以控制自己的导航项。如果要显示所按下VC的按钮/标题,则必须更新navigationItem。通常情况下,ViewWillDisplay是一个很好的位置。

是否从nib文件添加navigationController?是的。我正在使用故事板创建navigationController。在实例化WebViewController时,我使用WebViewController*orderVc=[self.window.rootViewController.storyboard InstanceEviewcontrollerWithiIdentifier:@“WebViewController”];在大多数情况下,使用pushViewController就可以了。但是从AppDelegate来看,虽然我可以使用presentViewController(这似乎表明self.window.rootViewController不是nil),但推送无法工作。感谢您的建议。但我只是想在现有的navigationController层次结构中添加一个viewcontroller。对不起,我的英语有点难解释这个问题。。。
UIViewController *currentVc = self.window.rootViewController;
[currentVc presentViewController:orderVc animated:NO completion:nil];