禁止navigation 第一个控制器的侧滑返回

  • (void)navigationController:(UINavigationController *)navigationController
    didShowViewController:(UIViewController *)viewController
    animated:(BOOL)animated
    {
    if ([navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
    if (self.viewControllers.count == 1) {// 禁止首页的侧滑返回
    navigationController.interactivePopGestureRecognizer.enabled = NO;
    }else{
    navigationController.interactivePopGestureRecognizer.enabled = YES;
    }

    }
    }

必须禁止第一个控制器的侧滑返回,因为,如果多次侧滑第一个控制器,会导致无法跳转问题。
这个问题找了好久,这里记录一下。

你可能感兴趣的:(ios)