美文网首页
ios 禁用系统手势返回功能

ios 禁用系统手势返回功能

作者: songjk | 来源:发表于2020-07-08 19:36 被阅读0次

    在控制器中添加如下代码即可

    -(void)viewDidAppear:(BOOL)animated
    {
        [super viewDidAppear:animated];
    // 禁用返回手势
        dispatch_async(dispatch_get_main_queue(), ^{
            if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
                self.navigationController.interactivePopGestureRecognizer.enabled = NO;
            }
        });
    }
    
    -(void)viewDidDisappear:(BOOL)animated
    {
        [super viewDidDisappear:animated];
    // 开启返回手势
        if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
            self.navigationController.interactivePopGestureRecognizer.enabled = YES;
        }
    }

    相关文章

      网友评论

          本文标题:ios 禁用系统手势返回功能

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