我有一个 MKMapView,它有很多注释。选择图钉显示标注并按下附件将新的 View Controller 弹出到堆栈上。但是,当我从那个新的 VC 中按回时,标注仍然打开。如何关闭它?
我试过了
if([[myMapView selectedAnnotations] count] > 0)
{
//deselect that annotation
[myMapView deselectAnnotation:[[myMapView selectedAnnotations] objectAtIndex:0] animated:NO];
}
但这行不通。 selectedAnnotations 在数组中确实有一个条目,所以它确实进入了这个语句,但标注没有关闭。
我是否需要向我的 MKAnnotation 实现或我的 MKPinAnnotationView 添加一些内容?
最佳答案
selectedAnnotations中的对象是MKAnnotation的实例
NSArray *selectedAnnotations = mapView.selectedAnnotations;
for(id annotation in selectedAnnotations) {
[mapView deselectAnnotation:annotation animated:NO];
}
关于iphone - 如何在 MKMapView 中关闭 MKAnnotation 的标注,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1193928/