有导航控制器push过后pop可以反回上一个界面,然而我们需要返回多级界面有下面两种方法
调用API
- (NSArray *)popToViewController:(UIViewController *)viewController animated:(BOOL)animated;
1.通过取得在导航控制器里面的控制器的下标 来返回
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:1] animated:YES];
2.遍历导航控制器里面的控制器找到想要返回的那一个
for (UIViewController *controller in self.navigationController.viewControllers) {
if ([controller isKindOfClass:[UserInfoControl class]]) {
[self.navigationController popToViewController:controller animated:YES];
}
}
时间: 2024-10-09 13:33:03