一,pop退出方式
2,pop到指定的控制器:
- 2.1通过获取
navigationController
获取到指定控制器i,然后pop
到指定控制器
UIViewController *targetVc = [self.navigationController.childViewControllers objectAtIndex:self.navigationController.childViewControllers.count - 4];
[self.navigationController popToViewController:targetVc animated:YES];
- 2.2 通过循环判断,找到指定类型的控制器,进行跳转
// 找到指定控制器
- (AGDemandDetailViewController *)getRootViewController{
AGDemandDetailViewController *rootViewController = nil;
for (UIViewController *vc in self.navigationController.viewControllers) {
if ([vc isKindOfClass:[AGDemandDetailViewController class]]) {
rootViewController = (AGDemandDetailViewController *)vc;
break;
}
}
return rootViewController;
}
// pop 到指定控制器
[self.navigationController popToViewController:[self getRootViewController] animated:YES];
网友评论