美文网首页
iOS返回到指定页

iOS返回到指定页

作者: XPGG | 来源:发表于2020-09-29 09:11 被阅读0次

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

    相关文章

      网友评论

          本文标题:iOS返回到指定页

          本文链接:https://www.haomeiwen.com/subject/hbdwyktx.html