popToViewController用法
方式一爷辙,不推薦
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:2] animated:YES];
方式二杂腰,推薦
for (UIViewController *controller in self.navigationController.viewControllers) {
if ([controller isKindOfClass:[你要跳轉(zhuǎn)到的Controller class]]) {
[self.navigationControllerpopToViewController:controller animated:YES];
}
}
方式三笑撞,推薦 這種方式可以適合返回指定控制器并調(diào)用其方法(比如刷新)
// 返回調(diào)用的控制器
LLXXXcontroller *myControl = nil;
for (int i = 0; i < self.navigationController.viewControllers.count; i++) {
CustomViewController *cv = self.navigationController.viewControllers[i];
if ([cv isKindOfClass:[LLXXXcontroller class]]) {
myControl = (LLXXXcontroller *)cv;
break;
}
}
[self.navigationController popToViewController:myControl animated:YES];
[myControl refreshData];