Xcode 将ViewController添加到现有UINavigation堆栈
如何在不使用initWithRootViewController的情况下在UINavigationController的顶部显示模态ViewController,只需将其添加到现有的navigationcontroller堆栈中即可 我的代码是:Xcode 将ViewController添加到现有UINavigation堆栈,xcode,uinavigationcontroller,Xcode,Uinavigationcontroller,如何在不使用initWithRootViewController的情况下在UINavigationController的顶部显示模态ViewController,只需将其添加到现有的navigationcontroller堆栈中即可 我的代码是: TableViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"TableView"]; UINavigationControll
TableViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"TableView"];
UINavigationController *navi = [[UINavigationController alloc] initWithRootViewController:controller];
[self presentViewController:navi animated:NO completion:nil];
编辑:我实际上想做的是:“vc1推vc2模式vc3”,然后使用“PoptRoot…到vc1”。但是initWithRootViewController(vc3)正在破坏它。如果您想更改navigationController的堆栈。使用:
- (void)setViewControllers:(NSArray *)viewControllers animated:(BOOL)animated NS_AVAILABLE_IOS(3_0); // If animated is YES, then simulate a push or pop depending on whether the new top view controller was previously in the stack.
这将有所帮助。呈现模式和添加到现有导航控制器是互斥的。可能您正在寻找
[self.navigationController pushViewController:controller animated:YES]代码>?!我不想用推。该代码在is下工作得非常好。我真正想做的是:“vc1推vc2模式vc3”,然后使用“PoptRoot…到vc1”。但是initWithRootViewController(vc3)正在破坏它。请尝试演示控制器而不是navi