美文网首页
导航栈里寻找navigationController

导航栈里寻找navigationController

作者: 精神薇 | 来源:发表于2018-02-08 17:53 被阅读0次

    1.栈里存在

    for (UIViewController *vc in [self.navigationController viewControllers]) {
            if ([vc isKindOfClass:[MonthlyExamDetailController class]]) {
                [self.navigationController popToViewController:vc animated:YES];
            }
    }
    

    2.栈里不存在

    NSMutableArray*tempMarr =[NSMutableArray arrayWithArray:self.navigationController.viewControllers];
    MonthlyExamDetailController *vc = [self.storyboard instantiateViewControllerWithIdentifier:NSStringFromClass([MonthlyExamDetailController class])];
    [tempMarr insertObject:vc atIndex:tempMarr.count- 1];
    [self.navigationController setViewControllers:tempMarr animated:YES];
    for (UIViewController *vc in [self.navigationController viewControllers]) {
                if ([vc isKindOfClass:[MonthlyExamDetailController class]]) {
                       [self.navigationController popToViewController:vc animated:YES];
                }
    }
    

    相关文章

      网友评论

          本文标题:导航栈里寻找navigationController

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