iOS 控制器多次present push后返回根控制器
2018-01-27 本文已影响0人
hope20
1
UIViewController *vc = self.presentingViewController;
if (!vc.presentingViewController) return;
while (vc.presentingViewController) {
vc = vc.presentingViewController;
}
[vc dismissViewControllerAnimated:YES completion:nil];
2
TargetVC *target = [[TargeVC alloc] init];
UIViewController *vc = self.presentingViewController;
if (!vc.presentingViewController) return;
while (![vc isKindOfClass:[target class]]) {
vc = vc.presentingViewController;
}
[vc dismissViewControllerAnimated:YES completion:nil];
3
if ([self respondsToSelector:@selector(presentingViewController)]) {
[self.presentingViewController.presentingViewController
dismissViewControllerAnimated:YES completion:nil];
}