美文网首页
iOS 控制器多次present push后返回根控制器

iOS 控制器多次present push后返回根控制器

作者: hope20 | 来源:发表于2018-01-27 00:22 被阅读0次

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

    }

    相关文章

      网友评论

          本文标题:iOS 控制器多次present push后返回根控制器

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