iOS dissmiss到指定控制器
程序员文章站
2022-06-04 13:18:19
...
[self dismissViewControllerClass:NSClassFromString(@"HomeViewController")];
- (void)dismissViewControllerClass:(Class)class {
UIViewController *vc = self;
while (![vc isKindOfClass:class] && vc != nil) {
vc = vc.presentingViewController;
if ([vc isKindOfClass:[UINavigationController class]]) {
vc = ((UINavigationController *)vc).viewControllers.lastObject;
}
}
[vc dismissViewControllerAnimated:YES completion:nil];
}