(推荐下面这种,不受控制器数量影响)
for (UIViewController *controller in self.navigationController.viewControllers) {
if ([controller isKindOfClass:[Controller class]]) {
[self.navigationController popToViewController:controller animated:YES];
}
}
方式三,推荐 这种方式适合返回指定控制器并调用其方法(比如刷新什么的)// 需要返回调用的
MylanController *myIVC = nil;
for (int i = 0; i < self.navigationController.viewControllers.count; i++) {
CustomViewController *cv = self.navigationController.viewControllers[i];
if ([cv isKindOfClass:[MylanController class]]) {
myIVC = (MylanController *)cv;
break;
}}
[self.navigationController popToViewController:myIVC animated:YES];
[myIVC refreshTableView];