Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/102.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/10.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 UINavigationController基于条件切换rootviewcontroller_Ios_Storyboard_Navigationcontroller - Fatal编程技术网

iOS UINavigationController基于条件切换rootviewcontroller

iOS UINavigationController基于条件切换rootviewcontroller,ios,storyboard,navigationcontroller,Ios,Storyboard,Navigationcontroller,我正在使用故事板编写一个iOS应用程序 我创建了ViewControllerA,ViewControllerB,然后将ViewControllerA嵌入到故事板上的UINavigationController中 应用程序首次启动时将显示ViewControllerA,否则将显示ViewControllerB 我成功添加了启动历史检查代码。我将在didfishlaunchwithoptions方法中将UINavigationController设置为窗口的rootViewController 问题

我正在使用故事板编写一个iOS应用程序

我创建了
ViewControllerA
ViewControllerB
,然后将
ViewControllerA
嵌入到故事板上的
UINavigationController

应用程序首次启动时将显示
ViewControllerA
,否则将显示
ViewControllerB

我成功添加了启动历史检查代码。我将在
didfishlaunchwithoptions
方法中将
UINavigationController
设置为窗口的
rootViewController


问题是我无法从情节提要获取
UINavigationController
,因此,我无法根据我的情况推送
ViewControllerA
ViewControllerB

如果您使用的是故事板,则应将
UINavigationController
设置为初始视图控制器,并自动加载和显示。现在,当在
ViewControllerA
中发生某些事情时,它可以使用以下命令推送
ViewControllerB

ViewControllerB *b = ...;
[self.navigationController pushViewController:b animated:YES];


为了增强篡改,应用程序代理具有一个
窗口
属性。从这里可以获得
rootViewController
。将其转换为
UINavigationController
,您可以修改/推送。将其设置为其他值,您可以一起替换
UINavigationController

我想将ViewControllerA或ViewControllerB显示为第一个屏幕。在上面的方法中,我可以隐藏ViewControllerA吗?如果我在appdelegate中添加上述代码,如何从appdelegate中的情节提要中获取ViewControllerA和B?[self.storyboard实例化eviewcontrollerwhiteIdentifier:@“ViewControllerA”];我找到了此代码,但self.storyboard在appdelegate中无效。