UIPanGestureRecognizer 触发次数过多
我有一个 UIPanGestureRecognizer,它根据我的喜好检测了太多次。我需要一个计数器并计算 3 个已完成的手势。每次我用手指平移识别器位置时,它都会触发 3 到 4 次。甚至触发了 5.
如何将识别器设置为检测较少,或者是什么导致它检测这么多次?
我想要连续 3 个单一检测。目前,这可能会导致对该函数进行 9 到 15 次调用。
I have a UIPanGestureRecognizer that is detecting far too many times for my liking. I need to have a counter and count 3 completed gestures. each time I pan with my finger in the recognizer spot, it triggers 3 or 4 times. has even triggered 5.
How can a recognizer be set to detect less, or what causes it to detect so many times?
I would like 3 single detections in a row. currently that could cause anything from 9 to 15 calls to the function.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需使用识别器的状态属性即可。如果 state == UIGestureRecognizerStateEnded 则调用您的函数。
Just use state property of your recognizer. Call your function if state == UIGestureRecognizerStateEnded.