gpt4 book ai didi

objective-c - UIWebView 和 UITapGestureRecognizer 上的 UIScrollView 冲突

转载 作者:行者123 更新时间:2023-11-28 17:36:37 25 4
gpt4 key购买 nike

我在 UIViewController 上有一个 UITapGestureRecognizer,里面有一个 UIScrollViewUIWebView。它仅在我滚动 UIWebView 后才识别点击手势。我怎么能阻止这个?基本上,当我不滚动 Web View 时,我希望检测到点击手势。我环顾四周,发现最接近的是:

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer*)otherGestureRecognizer {
return YES;
}

但不确定如何使用它来禁用滚动时的点击。任何想法?

我想做的另一件事是在单击 UIWebView 上的链接时禁用 UITapGestureRecognizer(调用 shouldStartLoadWebRequest)。在调用 shouldStartLoadWebRequest 之前,我检查了点击手势识别器是否被调用。基本上,当单击 UIWebView 上的链接时,它不应触发由 UITapGestureRecongnizer 调用的操作。关于如何执行此操作的任何想法?

最佳答案

所以苹果的文档strongly recommends你没有在 ScrollView 中嵌套 UIWebView:

Important: You should not embed UIWebView or UITableView objects in UIScrollView objects. If you do so, unexpected behavior can result because touch events for the two objects can be mixed up and wrongly handled.

在 iOS 5 及更高版本上可以直接访问 UIWebView(使用 scrollView)属性上的底层 ScrollView - 玩这个 可能对你有帮助。

关于objective-c - UIWebView 和 UITapGestureRecognizer 上的 UIScrollView 冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9653257/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com