2020-03-27

关于ios中 viewcontroller的跳转问题,其中有一种方式是采用navigationController pushViewController 的方法,比如我从主页面跳转到了一级页面,又从一级页面跳转到了二级页面,然后从二级页面跳转到了三级页面,依次类推。,如果一级一级的返回我知道是没有问题的.



           UIViewController *vc =self.navigationController.viewControllers[1];

            [self.navigationController popToViewController:vc animated:YES];







你自己算 你是第几级界面  然后pop回去就可以了

方法二:

UINavigationController *nav = self.navigationController;

        NSMutableArray *viewControllers = [[NSMutableArray alloc]init];

        for (UIViewController *vc in [nav viewControllers]) {

            [viewControllers addObject:vc];

            if ([vc isKindOfClass:[youNeedJumpVC class]]) {

                break;

            }

        }

        [nav setViewControllers:viewControllers animated:YES];







for(UIViewController*controllerinself.navigationController.viewControllers){
      if([controller isKindOfClass:[AViewController class]]){
          AViewController*A=(AViewController*)controller;
        [self.navigationController popToViewController:A animated:YES];
}
}

你可能感兴趣的:(2020-03-27)