CGRectContainsPoint 的多指 UIPanGestureRecognizer 行为

发布于 2024-11-18 17:12:04 字数 442 浏览 4 评论 0原文

我有一个主视图,分为 4 个大小相等的子视图。我使用 UIPanGestureRecognizer 和 3 个手指来触发一个事件,该事件基于使用 CGRectContainsPoint 方法的这 4 个视图中的 1 个。

我的目标是,当运动开始/结束时,三个手指必须位于同一视图中,才能触发该视图的适当事件处理。

问题是,如果我从不在同一视图中的 3 个手指开始(视图 1 中的 2 个手指和视图 2 中的 1 个手指等),则触发的事件处理是最后有 2 个手指的事件处理,因为我使用的是 UIGestureRecognizerStateEnded 是否有一种技术

可以确保当且仅当 3 个手指从同一视图 (CGRect) 开始并以同一视图 (CGRect) 结束时触发事件处理?

顺便说一句:我对其他 UIXXXGestureRecognizer 使用相同的过程,它们都按设计工作。

谢谢。

I have a main view that divided into 4 equally sized sub-views. I used UIPanGestureRecognizer with 3 fingers to trigger an event based on which 1 of those 4 views using the CGRectContainsPoint method.

My goal is that three fingers have to be in the same view when the motion started/ended to trigger the appropriated event handling for that view.

The problem was that if I start with my 3 fingers not in the same view (2 fingers in view1 and 1 finger in view2 etc.) The event handling that got triggered was the one with 2 fingers at the end since I am using the UIGestureRecognizerStateEnded method etc.

Is there a technique to make sure that the event handling get triggered if and only if 3 fingers started at the same view (CGRect) and ended with the same view (CGRect)?

btw: I am using the same procedure for other UIXXXGestureRecognizer and they all worked as designed.

Thank you.

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

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

发布评论

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

评论(1

愁杀 2024-11-25 17:12:04

我只是比较了 UIGestureRecognizerStateBegan 状态的位置和 UIGestureRecognizerStateEnded 的位置,以确保它位于特定视图内。

I just compared the location for UIGestureRecognizerStateBegan state and the location for UIGestureRecognizerStateEnded to make sure it is within the specific view.

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