修改pop回去的页面

1.如果是点击界面上的按钮pop,想返回上几级,用如下方法:

    for (UIViewController *vc in self.navigationController.viewControllers) {
          if ([vc isKindOfClass:[InfomationViewController class]]) {
              [self.navigationController popToViewController:vc animated:YES];
          }
    }

2.如果是点击系统的左上角返回按钮,想pop到想要的页面

    -(void)_changeBackButtonAction{
      //在navigationController.viewControllers里面,把不需要的页面删掉。
      //一定要写break,否则会崩溃。
        NSMutableArray *array = [[NSMutableArray alloc]initWithArray:self.navigationController.viewControllers];
        for (UIViewController *vc in array) {
            if ([vc isKindOfClass:[ChangePhoneOrPassworldViewController class]]) {
                [array removeObject:vc];
                break;
            }
        }
        for (UIViewController *vc in array){
            if ([vc isKindOfClass:[InputOldPsdViewController class]]) {
                [array removeObject:vc];
                break;
            }
        }
        self.navigationController.viewControllers = array;
        
    }

推荐阅读更多精彩内容