iOS self.navigationController 推出界面怎么一次性回到指定第一个

A->B->C

想要从C一步回到A

 

//判断要回退的指定界面是否与遍历的界面相同

            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{

               

                UINavigationController *naviVc = self.navigationController;//self.navigationController表示本界面

                

                for (UIViewController *vc in [naviVc viewControllers]) {//遍历一路跳转到本界面以来的所有界面

                    

                    

                    if ([vc isKindOfClass:[B class]] || [vc isKindOfClass:[A class]])

                    {

                        [self.navigationController popToViewController:vc animated:YES];//执行回退动作

                    }

                }

            });

 

posted @ 2020-01-08 16:20  liuw_flexi  阅读(355)  评论(0编辑  收藏  举报