手动设置 UINavigationController Children

Manually Set UINavigationController Children

我在导航控制器中有两个 children(根 child 和第二个 child)。我通常转到根目录 child,然后转到第二个 child。这允许我使用导航控制器按钮返回到根目录 child(它的状态与我离开它时的状态相同)。

有没有办法在根 child 上手动设置属性,但在第二个 child 上启动导航控制器?

我目前的做法是在根 child 上设置属性,然后转到第二个 child 但我不想等待根 child 控制器加载然后等待 segue。

您可以实例化这两个子视图控制器,并根据需要配置它们的属性,然后使用:

- (void)setViewControllers:(NSArray *)viewControllers animated:(BOOL)animated

将它们加载到导航控制器中。见 Apple Docs here:

"Use this method to update or replace the current view controller stack without pushing or popping each controller explicitly. In addition, this method lets you update the set of controllers without animating the changes, which might be appropriate at launch time when you want to return the navigation controller to a previous state."