【发布时间】:2013-06-14 10:34:00
【问题描述】:
在基于用户选择的 Home ViewController 中,我必须加载选定的 viewcontroller。为此,我将 AppDelegate.window.rootViewController 更改为使用选定视图控制器启动的导航控制器。
例如:
navigationController = [[UINavigationController alloc] initWithViewController:selectedViewController];
[UIApplication delegate].window.rootviewcontroller = navigationController;
这一切都很好,但我的问题是:从 selectedViewController 我导航到一些 n no.of viewcontrollers,最后我通过设置 appdelegate 的 rootviewcontroller 来加载 HomeViewController。
navigationController = [[UINavigationController alloc] initWithViewController:homeViewController];
[UIApplication delegate].window.rootviewcontroller = navigationController;
这会清除我之前的 navigationController 导航堆栈吗?还是我应该从外部清除阵列?可能解释一下当我们将导航控制器分配给 appdelegate 的窗口 rootviewcontroller 时会发生什么?
请注意,我的应用程序是 6.0 版本。
【问题讨论】:
-
为什么每次都要重置rootviewcontroller?
-
好吧,我不应该更改它的现有代码。可能是出于某种目的,但在这里我必须确保在更改 rootviewcontroller 时导航堆栈为空。
标签: ios ipad uinavigationcontroller appdelegate uiwindow