如何在地图视图中始终显示标注?如果我们点击地图视图标注,隐藏并再次点击图钉,它就会显示出来。我不想这样,我需要总是显示标注,而不是隐藏。如何做到这一点。请帮帮我。我使用下面的代码来显示标注。它不能很好地工作。
[mapView selectAnnotation:addAnnotation animated:NO];
annotationView.canShowCallout = YES;发布于 2012-10-20 15:07:49
您可以使用MKMapView的delegate方法didDeselectAnnotationView来完成此操作,并在取消选择时选择相同的annotation,如下所示-
- (void)mapView:(MKMapView *)mapView didDeselectAnnotationView:(MKAnnotationView *)view
{
[mapView selectAnnotation:view.annotation animated:FALSE];
}发布于 2012-10-20 15:00:33
选择MKAnnotationView并将视图的canShowCallout属性设置为YES时,将显示详图索引。
然后在取消选择该MKAnnotationView时将其隐藏。单击另一个注释视图,或在当前选定的注释视图外部单击,即可执行此操作。
作为MKMapView (符合MKMapViewDelegate)的代表,当注释视图被选中和取消选中时,您会被告知,但是对此做任何事情都为时已晚。
如果不想取消选择注释视图,则应该创建MKAnnotationView子类并覆盖setSelected:animated:方法,并阻止注释视图被取消选择。
编辑:
如果代码中存在此方法,则将其删除
- (void)deselectAnnotation:(id < MKAnnotation >)annotation animated:(BOOL)animatedhttps://stackoverflow.com/questions/12986053
复制相似问题