本文介绍了在MKMapView中显示多个注释标注的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以同时打开多个标注?
Is it possible to open simultaneously more then one callout?
代码:
- (void)mapViewDidFinishLoadingMap:(MKMapView *)theMapView {
for (id<MKAnnotation> currentAnnotation in theMapView.annotations) {
[theMapView selectAnnotation:currentAnnotation animated:YES];
}
}
只打开一个标注。
推荐答案
注意 MKMapView
上有一个方法(不是 MKAnnotationView
)用于以编程方式选择一个或多或少有效的注释:
Note that there is a method on MKMapView
(not MKAnnotationView
) for selecting an annotation programmatically that works more or less as you would expect:
- (void)selectAnnotation:(id < MKAnnotation >)annotation animated:(BOOL)animated
然而,它会自动同时取消选择任何当前注释,这样就无法解决您的问题。
However, it automatically deselects any currently annotation at the same time so this doesn't solve your problem.
奇怪的是, MKMapView上有一个属性
似乎包含当前所选注释的数组:
Oddly, there is a property on MKMapView
that appears to hold an array of currently selected annotations:
@property(nonatomic, copy) NSArray *selectedAnnotations
但是这个方法的文档说:
But the documentation on this method says:
只是觉得这可能是有意义的。
Just thought this might be of interest.
这篇关于在MKMapView中显示多个注释标注的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!