ios - 如何在 presentViewController 之后禁用 SFSafariViewController 中的滑动手势
问题描述
我编写了以下代码来禁用 SFSafariViewController 中的滑动弹出手势。但它不起作用。
self.navigationController.interactivePopGestureRecognizer.enabled = NO;
self.navigationController.interactivePopGestureRecognizer.delegate = (id<UIGestureRecognizerDelegate>)self;
我还添加了委托方法
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer
shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
return YES;
}
但它永远不会被调用。请帮我禁用弹出手势。
解决方案
请覆盖presentationControllerShouldDismiss 并在该方法中返回false。
- (BOOL)presentationControllerShouldDismiss:(UIPresentationController *)presentationController{
return NO;
}
或者您可以尝试为 SFSafariViewController 对象将 modalInPresentation 参数设置为 YES 吗?因为根据文档,它说...
此属性的默认值为 NO。当您将其设置为 YES 时,UIKit 会忽略视图控制器范围之外的事件,并防止视图控制器在屏幕上的交互解除。
推荐阅读
- javascript - 在 plotly.js 中添加百分比符号来衡量指标
- java - 无法弄清楚为什么循环没有得到正确的总和
- html - 在 Angular 中为 mat-cards 创建一个搜索栏?
- string - 最长公共前缀 - 比较两种算法的时间复杂度
- c++ - 通过组节点的二维向量手动迭代
- c# - C#使用Newtonsoft Json根据属性更改列表中项目的属性名称
- swift - 删除 Firestore SnapshotListener
- python - 如何在访问语料库中的文件时修复 FileNotFoundError
- sql - 在 R 中的 SQL 脚本中使用的 R readline 提示
- django - Django Localization:如果嵌入了链接,我们如何正确翻译字符串?