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];//执行回退动作

                    }

                }

            });

猜你喜欢

转载自www.cnblogs.com/liuw-flexi/p/12167287.html