Disable all user interaction for MKMapView except for a given MKAnnotationView

1.5k views Asked by At

I have a MKMapView and a few MKAnnotationViews on my map.

When a certain event happens, I would like to disable user interaction on my MKMapView but leave interaction on my MKAnnotationView available.

Ideally, it would be

self.mapView.userInteraction = NO;
self.myAnnotationView.userInteraction = YES;

Printing

[self.mapView recursiveDescription]

I have found that my annotation view is nested in MKNewAnnotationContainerView which doesn't have a publicly exposed property on Apple's class reference.

Any ideas?

1

There are 1 answers

1
AudioBubble On BEST ANSWER

On the mapView, set scrollEnabled, zoomEnabled, pitchEnabled, and rotateEnabled to NO and leave userInteractionEnabled as YES.

This way, the annotation views will still be enabled.

For pitchEnabled and rotateEnabled, you may want to check if those properties exist before setting them (eg. check if the map view respondsToSelector:@selector(setPitchEnabled), etc.) since they were added in iOS 7.