简体   繁体   English

禁用MKMapView的所有用户交互,但给定的MKAnnotationView除外

[英]Disable all user interaction for MKMapView except for a given MKAnnotationView

I have a MKMapView and a few MKAnnotationViews on my map. 我的地图上有一个MKMapView和一些MKAnnotationViews。

When a certain event happens, I would like to disable user interaction on my MKMapView but leave interaction on my MKAnnotationView available. 当某个事件发生时,我想在我的MKMapView上禁用用户交互,但在我的MKAnnotationView上保留交互。

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. 我发现我的注释视图嵌套在MKNewAnnotationContainerView中,它在Apple的类引用上没有公开的属性。

Any ideas? 有任何想法吗?

On the mapView, set scrollEnabled , zoomEnabled , pitchEnabled , and rotateEnabled to NO and leave userInteractionEnabled as YES . 在mapView上,将scrollEnabledzoomEnabledpitchEnabledrotateEnabledNO并将userInteractionEnabled保留为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. 对于pitchEnabledrotateEnabled ,您可能希望在设置它们之前检查这些属性是否存在(例如,检查地图视图respondsToSelector:@selector(setPitchEnabled)等),因为它们是在iOS 7中添加的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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