我有六个viewControllers。在viewController1上,我有一个button,它将带我到viewController6

现在从viewController6我想分别弹出到viewController5viewController4viewController3viewController2viewController1

我怎样才能做到这一点?

最佳答案

试试这个,

NSMutableArray *allViewControllers = [NSMutableArray arrayWithArray: self.navigationController.viewControllers];

使用依次插入所需的视图控制器
[allViewControllers insertObject:viewControllerX atIndex:requiredIndex];

如果您只想替换先前的viewController使用,
 [allViewControllers replaceObjectAtIndex:indexRequired withObject:viewControlerX];

然后放回导航堆栈,
self.navigationController.viewControllers = allViewControllers;

然后,您可以使用以下命令弹出任何viewController:
[self.navigationController popViewControllerAnimated:YES];

关于iphone - 我如何在导航 Controller 中弹出,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14396522/

10-09 09:05