ios跳转popToViewController的使用

ios提供的navigation条状方法一共有三种

1. - (nullable UIViewController *)popViewControllerAnimated:(BOOL)animated;

2. - (nullable NSArray<__kindof UIViewController *> *)popToViewController:(UIViewController *)viewController

animated:(BOOL)animated;

3. - (nullable NSArray<__kindof UIViewController *> *)popToRootViewControllerAnimated:(BOOL)animated;


常用的如下:

[self.navigationControllerpopToViewController:[self.navigationController.viewControllersobjectAtIndex:2]animated:YES];

for(UIViewController*temp inself.navigationController.viewControllers) {

if([tempisKindOfClass:[你要跳转到的Controllerclass]]) {

[self.navigationControllerpopToViewController:tempanimated:YES];

      }

}

推荐阅读更多精彩内容