1 方法一
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:2]
animated:YES];2 方法二 for (UIViewController *temp in self.navigationController.viewControllers) { if ([temp isKindOfClass:[你要跳转到的Controller class]]) { [self.navigationController popToViewController:temp animated:YES]; } }
3 方法三
通过self.navigationController.viewControllers获得各层次的控制器数组,然后removeLastObject依次从最顶层删除其子控制器,直至需要的位置不再removeLastObject或者如下面再添加一个新控制器LB_OrderControlle,此时,点击LB_OrderControlle控制器对应的返回按钮pop时,会返回到第控制器数组的(self.navigationController.viewControllers.count - 3)位置对应的控制器LB_PlaceAnOrderViewController:
下面是po的控制器数组:
po self.navigationController.viewControllers
<__NSArrayI 0x60000086b4c0>(
<MCenterViewController: 0x7ffba0550170>,
<LB_PlaceAnOrderViewController: 0x7ffba2c26780>,
<LB_OrderCenterVC: 0x7ffba072f560>,
<LB_CenterDetailOrderVC: 0x7ffba04e7920>,
<LB_AccountReceivableSuccessViewController: 0x7ffba2c04fd0>
)
实现代码:
NSMutableArray *arr = self.navigationController.viewControllers.mutableCopy;
[arr removeLastObject]; // 第一个remove
[arr removeLastObject]; // 第二个remove
[arr removeLastObject]; // 第三个remove
LB_OrderController *vc = [LB_OrderController new];
[arr addObject:vc];
self.navigationController.viewControllers = arr.copy;