简体   繁体   中英

Disable all user interaction for MKMapView except for a given MKAnnotationView

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM