Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.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
Xcode 将ViewController添加到现有UINavigation堆栈_Xcode_Uinavigationcontroller - Fatal编程技术网

Xcode 将ViewController添加到现有UINavigation堆栈

Xcode 将ViewController添加到现有UINavigation堆栈,xcode,uinavigationcontroller,Xcode,Uinavigationcontroller,如何在不使用initWithRootViewController的情况下在UINavigationController的顶部显示模态ViewController,只需将其添加到现有的navigationcontroller堆栈中即可 我的代码是: TableViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"TableView"]; UINavigationControll

如何在不使用initWithRootViewController的情况下在UINavigationController的顶部显示模态ViewController,只需将其添加到现有的navigationcontroller堆栈中即可

我的代码是:

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