iOS dissmiss到指定控制器

[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];
}

你可能感兴趣的:(iOS dissmiss到指定控制器)