使用 UIGestureRecognizer 同时识别触摸和点击手势
是否可以使用 UIGestureRecognizer 同时处理触摸和点击手势识别?
Is it possible to handle Touch and Tap gestures recognition simultaneously with UIGestureRecognizer?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道你指的是哪种触摸识别器,但我想你指的是像平底锅这样的东西。但是,是的,这是可能的,只需创建多个手势识别器即可。示例:
我假设您了解手势识别器的基础知识。如果没有,我很乐意为您提供教程链接并帮助您解决任何其他问题。
但是,如果它们都使用相同类型的手势(例如平移和滑动,或者单击和双击识别器),则您将需要使用 requiresgesturerecognizertofail。
I don't know what kind of recognizer you mean with touch, but i suppose you mean something like pan. But yes, it is possible, simply by creating multiple gesturecognizers. Example:
I'm assuming you know the basics of gesturerecognizers. If not, i'll be happy to give you a link to a tutorial and help you with any additional questions.
However, if they both use the same kind of gesture (like pan and swipe, or a single and double tap recognizer), you will need to use requiresgesturerecognizertofail.
只要将手势上的cancelsTouchesInView 设置为NO,就可以使用触摸方法和手势。
You can use touch methods and gestures as long as you set cancelsTouchesInView to NO on the gesture.