- 方式1(自我感觉不到迫不得已慎用,可能会造成层级架构错误):返回到AS_ZBPersonnelAssessmentDetailVC控制器。弊端:无法返回到导航控制器中最外层的控制器,可以利用方式2解决
for (UIViewController *VC in self.navigationController.viewControllers) {
if ([VC isKindOfClass:[AS_ZBPersonnelAssessmentDetailVC class]]) {
[self.navigationController popToViewController:VC animated:NO];
}
}
-方式2:因为控制器都是压栈进去的,所以第0个最先push的控制器
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:0] animated:YES];
返回到前两个界面
NSInteger indexValue = (NSInteger)[[self.navigationController viewControllers] indexOfObject:self];
if (indexValue > 2) {
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:(indexValue - 2)] animated:YES];
}