I am working on my custom gesture on the map. It should work after 2s long press. All is fine, but after long press gesture I move fingers and map follows them... I need to escape this. I tried:
self.mapView.userInteractionEnabled = NO;
But it seems not working...
Working way. Collect all working on UIMapView
gesture recognizers:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
if (gestureRecognizer == self.myLongPressGestureRecognizer
&& otherGestureRecognizer != self.myPanGestureRecognizer)
{
if (self.otherGestureRecognizers == nil)
self.otherGestureRecognizers = [NSMutableSet set];
[self.otherGestureRecognizers addObject:otherGestureRecognizer];
}
return YES;
}
And cancel them all when your gesture recognizer recognized:
- (IBAction)measureLongPressed:(UILongPressGestureRecognizer *)recognizer
{
if (recognizer.state == UIGestureRecognizerStateBegan)
{
self.mapView.userInteractionEnabled = NO;
for (UIGestureRecognizer *gr in self.otherGestureRecognizers)
{
gr.enabled = NO;
gr.enabled = YES;
}
self.otherGestureRecognizers = nil;
[self myLongPressDetectedAndMapFreezed];
return;
}
}