美文网首页iOS项目遇到的问题
单个页面禁止右滑返回手势

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

作者: 丶王无情 | 来源:发表于2020-04-07 16:15 被阅读0次

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

- (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;

        }

    }

}

相关文章

网友评论

    本文标题:单个页面禁止右滑返回手势

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