方法一:
- (void)backToAppointedController1 {
// 直接查找你需要跳转的界面 不会算的话自己从1开始试吧 、此法需要知道你返回到的控制器的位置
UIViewController *viewC = [self.navigationController.viewControllers objectAtIndex:index];
[self.navigationController popToViewController:viewC animated:YES];
}
方法二:
- (void)backToAppointedController2 {
// 此法只需要知道你需要返回的控制器的类名称即可
UINavigationController *navC = self.navigationController;
NSMutableArray *viewControllers = [[NSMutableArray alloc] init];
for (UIViewController *vc in navC.viewControllers) {
[viewControllers addObject:vc];
if ([vc isKindOfClass:[YourController Class]]) {
break;
}
}
if (viewControllers.count == navC.viewControllers.count) {
[self.navigationController popViewControllerAnimated:YES];
}
else {
[navC setViewControllers:viewControllers animated:YES];
}
}
方法三:将中间控制器删除
- (void)backToAppointedController3 {
//得到当前视图控制器中的所有控制器
NSMutableArray *array = [self.navigationController.viewControllers mutableCopy];
//把B从里面删除
[array removeObjectAtIndex:1];
//把删除后的控制器数组再次赋值
[self.navigationController setViewControllers:[array copy] animated:YES];
}