单个页面禁止右滑返回手势

需要禁止右滑返回的页面添加:

- (void)viewWillDisappear:(BOOL)animated

{

    [superviewWillDisappear:animated];

    // 打开返回手势

    if([self.navigationControllerrespondsToSelector:@selector(interactivePopGestureRecognizer)]) {

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

            popGesture.enabled=YES;

        }

    }

}

-(void)viewDidAppear:(BOOL)animated{

    [superviewDidAppear:animated];

    // 禁用右滑返回手势

    if([self.navigationControllerrespondsToSelector:@selector(interactivePopGestureRecognizer)]) {

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

            popGesture.enabled=NO;

        }

    }

}

你可能感兴趣的:(单个页面禁止右滑返回手势)