iOS禁止手势侧滑(遍历禁止)

首先写这个方法

-(void)popGestureChange:(UIViewController *)vc enable:(BOOL)enable{

    if ([vc.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {

        //遍历所有的手势

        for (UIGestureRecognizer *popGesture in vc.navigationController.interactivePopGestureRecognizer.view.gestureRecognizers) {

            popGesture.enabled = enable;

        }

    }

}


然后在viewDidAppear这个方法里面调用

- (void)viewDidAppear:(BOOL)animated{

    [superviewDidAppear:animated];

    [self popGestureChange:self enable:NO];

}

你可能感兴趣的:(iOS禁止手势侧滑(遍历禁止))