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];
}
}
网友评论