首先要满足跳转的时候是通过navigationController 一层层push过去,当想要再退回某一指定控制器的时候有两种方法(这两种方法,我都试了一下,都可以满足我的需求):
①
//objectAtIndex后面的参数就是你想要返回的控制器在navigationController.viewControllers的下标
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:0] animated:YES]
②
//LoginViewController是指定的要返回的控制器
for (UIViewController *controller in self.navigationController.viewControllers) {
if ([controller isKindOfClass:[LoginViewController class]]) {
[self.navigationController popToViewController:controller animated:YES];
}
}