Reputation: 2031
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.
Upvotes: 2
Views: 1813
Reputation: 358
Have you seen this question ?
For using my UILongPressGestureRecognizer I disabled AnnotationView and added GestureRecognizer to it:
[ann_view setEnabled:NO];
UILongPressGestureRecognizer* long_press = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressAnnotationView:)];
long_press.minimumPressDuration = 1.5;
[ann_view addGestureRecognizer:long_press];
[long_press release];
Upvotes: 3