I struggle with that. I have a map with many contacts in a small area. I want to ignore the choice of the type of annotation when I click on the map for a long time, regardless of whether I click on the annotation. It seems that the annotation is selected on touchDown, rather than being pressed internally on the annotation view, which is annoying.
I added a longpress gesture to the map:
UILongPressGestureRecognizer *longRec = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(addPin:)];
longRec.cancelsTouchesInView = YES;
[self.mapView addGestureRecognizer:longRec];
This is not recognized when I click on the annotation for a long time. As soon as I click the "Delete" button, the annotation processing request is processed, and a long press never works.
I tried to block the click gesture recognizer, which of course does not work, because the mapview display gesture is not passed to my map display controller, so this does not work:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
if ([gestureRecognizer isKindOfClass:[UITapGestureRecognizer class]] && [otherGestureRecognizer isKindOfClass:[UILongPressGestureRecognizer class]]) {
return NO;
}
return YES;
}
I also tried adding a longpress gesture to the presentation of the annotation as a hack, but it never starts, and I still don't like this strategy.
Is there a way to block the selection of the mapview annotation when the longpress gesture is pending review on the map?
source
share