iOS返回到指定页

2020-09-29  本文已影响0人  XPGG

1.当页面是present出来时

UIViewController *vc = self.presentingViewController;
while (![vc isKindOfClass:[TargetViewController class]]) {
    vc = vc.presentingViewController;
}
[vc dismissViewControllerAnimated:YES completion:nil];

2.当页面是push出来时

for (UIViewController *controller in self.navigationController.viewControllers) {
       if ([controller isKindOfClass:[TargetViewController class]]) {
            TargetViewController *vc = (TargetViewController *)controller;
            [self.navigationController popToViewController:vc animated:YES];
       }
}
上一篇下一篇

猜你喜欢

热点阅读