MKAnnotationView 上的 UILongPressGestureRecognizer 不适用于单点触摸
我一直在尝试在 MKAnnotationView
子类中使用 UILongPressGestureRecognizer
。有趣的是,手势识别器仅在使用两个手指/触摸时触发。
是什么阻止手势识别器仅通过一次触摸就被触发?
实现
UILongPressGestureRecognizer *pressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self
action:@selector(handleLongPress:)];
pressRecognizer.minimumPressDuration = 0.25;
pressRecognizer.numberOfTapsRequired = 0;
pressRecognizer.numberOfTouchesRequired = 1;
普通 UIView
中的相同实现显示了一键式操作的预期行为。然而,可以使用 touchesBegan:
和 touchesEnded:
来获得长按手势,我仍然很好奇这是什么原因。
I've been trying to use a UILongPressGestureRecognizer
in a MKAnnotationView
subclass. Interestingly the gesture recognizer only triggers when using two ore fingers/touches.
What prevents the gesture recognizer to get triggered with only one touch?
Implementation
UILongPressGestureRecognizer *pressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self
action:@selector(handleLongPress:)];
pressRecognizer.minimumPressDuration = 0.25;
pressRecognizer.numberOfTapsRequired = 0;
pressRecognizer.numberOfTouchesRequired = 1;
The same implementation in a normal UIView
shows the expected behaviour working with one touch. Yet it's possible to use touchesBegan:
and touchesEnded:
to get a long press gesture working I'm still curious what the reason for this is.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您见过这个问题吗?
为了使用我的 UILongPressGestureRecognizer,我禁用了 AnnotationView 并向其中添加了 GestureRecognizer:
Have you seen this question ?
For using my UILongPressGestureRecognizer I disabled AnnotationView and added GestureRecognizer to it: