UINavigationController类有个属性ViewControllers,这是一个数组,记录了导航栈中的ViewController,所以要跳转到指定的页面就要使用这个属性,代码如下:
for (UIViewController *vc in self.navigationController.viewControllers) {
if ([vc isKindOfClass:[SearchUserViewController class]]) {
[self.navigationController popToViewController:vc animated:YES];
}
}
其中SearchUserViewController是要跳转的页面。