CGRectContainsPoint 的多指 UIPanGestureRecognizer 行为
我有一个主视图,分为 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我只是比较了 UIGestureRecognizerStateBegan 状态的位置和 UIGestureRecognizerStateEnded 的位置,以确保它位于特定视图内。
I just compared the location for UIGestureRecognizerStateBegan state and the location for UIGestureRecognizerStateEnded to make sure it is within the specific view.