美文网首页
UINavigationController---pop到指定c

UINavigationController---pop到指定c

作者: 那个下午 | 来源:发表于2016-07-05 16:36 被阅读71次

    方法一:

    //指定要pop到的控制器层级
    UIViewController *viewCtl = self.navigationController.viewControllers[2];
    
        [self.navigationController popToViewController:viewCtl animated:YES];
    

    方法二:

    HomeViewController *homeVC = [[HomeViewController alloc] init]; 
    UIViewController *target = nil; 
    for (UIViewController * controller in self.navigationController.viewControllers) { //遍历 
    if ([controller isKindOfClass:[homeVC class]]) { //这里判断是否为你想要跳转的页面 
    target = controller; 
    } 
    } 
    if (target) { 
    [self.navigationController popToViewController:target animated:YES]; //跳转 
    } 
    

    相关文章

      网友评论

          本文标题:UINavigationController---pop到指定c

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