我的 map 上有一个 MKMapView 和一些 MKAnnotationViews。
当某个事件发生时,我想禁用我的 MKMapView 上的用户交互,但让我的 MKAnnotationView 上的交互可用。
理想情况下,它将是
self.mapView.userInteraction = NO;
self.myAnnotationView.userInteraction = YES;
打印
[self.mapView recursiveDescription]
我发现我的注释 View 嵌套在 MKNewAnnotationContainerView 中,它在 Apple 的类引用中没有公开的属性。
有任何想法吗?
最佳答案
在 mapView 上,设置 scrollEnabled
, zoomEnabled
, pitchEnabled
, 和 rotateEnabled
至NO
离开userInteractionEnabled
如YES
.
这样,注释 View 仍将启用。
对于 pitchEnabled
和 rotateEnabled
,您可能需要在设置它们之前检查这些属性是否存在(例如,检查 map View 是否 respondsToSelector:@selector(setPitchEnabled)
等),因为它们是在 iOS 7 中添加的。
关于ios - 禁用 MKMapView 的所有用户交互,除了给定的 MKAnnotationView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20351364/