UITapGestureRecognizer 与 UIPinchGestureRecognizer 交互

发布于 2025-01-07 21:35:07 字数 629 浏览 1 评论 0原文

我有一个视图控制器,它将 UITapGestureRecognizer 附加到其主 UIView,并允许用户点击屏幕以使状态、导航和工具栏重新出现/消失(就像照片应用程序一样)。我还有一个附加到主 UIViewUIScrollView ,它实现了缩放,因此有自己的 UIPinchGestureRecognizerUIPanGestureRecognizer实现滚动和缩放。

我遇到的问题是,当要缩放/滚动 UIScrollView 时,它对拾取附加到主 UIViewUITapGestureRecognizer 非常敏感/代码>。似乎很多时候 UITapGestureRecognizer 都会在不应该触发的时候被触发。有人知道如何修复低于 5.0 的 ios 版本吗?有什么办法可以覆盖 UIScrollViewUIGestureRecognizerDelegate 的同步手势委托方法,并防止 UITapGestureRecognizer 在其他手势期间触发?

I have a view controller that attaches a UITapGestureRecognizer to its main UIView, and enables the user to tap the screen to make the status, navigation, and tool bars reappear / disappear (like the photos app). I also have a UIScrollView attached to the main UIView which implements zooming and thus has its own UIPinchGestureRecognizer and UIPanGestureRecognizer to implement scrolling and zooming.

The problem I'm having, is when going to zoom / scroll the UIScrollView, it's very sensitive to picking up the UITapGestureRecognizer which is attached to the main UIView. It seems a lot of the time the UITapGestureRecognizer gets triggered when it shouldn't. Anyone have any ideas on how to fix this for versions of ios below 5.0? Is there someway I can override the simultaneous gestures delegate method for the UIGestureRecognizerDelegate in the UIScrollView and prevent the UITapGestureRecognizer from firing during other gestures?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ぺ禁宫浮华殁 2025-01-14 21:35:07

使用 requireGestureRecognizerToFail: 方法。

[tapGestureRecognizer requireGestureRecognizerToFail:pinchGestureRecognizer];

此调用告诉点击识别器等待捏合识别器失败。

Use the requireGestureRecognizerToFail: method.

[tapGestureRecognizer requireGestureRecognizerToFail:pinchGestureRecognizer];

This call tells the tap recognizer to wait for the pinch recognizer to fail.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文