我有一个 navigationController,它显示为 modalview,它的 rootviewcontroller 是 FirstViewController。在某些时候我想将 navigationController 的 rootviewcontroller 更改为 SecondViewController。我所做的是
[self.navigationController initWithRootViewController:SecondViewController];
我不确定我所做的是否正确以及 FirstViewController 是否已发布?请问有人知道这样做的正确方法是什么吗?
提前致谢!
最佳答案
做任何一个
[firstViewController.navigationController setViewControllers: [NSArray arrayWithObject: secondViewController]
animated: YES];
或
firstViewController.navigationController.viewControllers = [NSArray arrayWithObject: secondViewController];
firstViewController
是 FirstViewController
的实例,secondViewController
是 SecondViewController
类的实例。后一种变体是 setViewControllers:animated:
没有动画的快捷方式。
关于objective-c - 如何更改 NavigationController 的 rootviewcontroller?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10225401/