首页 > 解决方案 > 如何在 presentViewController 之后禁用 SFSafariViewController 中的滑动手势

问题描述

我编写了以下代码来禁用 SFSafariViewController 中的滑动弹出手势。但它不起作用。

self.navigationController.interactivePopGestureRecognizer.enabled = NO;
self.navigationController.interactivePopGestureRecognizer.delegate = (id<UIGestureRecognizerDelegate>)self;

我还添加了委托方法

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer
shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {

    return YES;
}

但它永远不会被调用。请帮我禁用弹出手势。

标签: iosobjective-ciphone

解决方案


请覆盖presentationControllerShouldDismiss 并在该方法中返回false。

- (BOOL)presentationControllerShouldDismiss:(UIPresentationController *)presentationController{
   return NO;
}

或者您可以尝试为 SFSafariViewController 对象将 modalInPresentation 参数设置为 YES 吗?因为根据文档,它说...

此属性的默认值为 NO。当您将其设置为 YES 时,UIKit 会忽略视图控制器范围之外的事件,并防止视图控制器在屏幕上的交互解除。


推荐阅读