jon*_*wah 17 iphone objective-c
我有一个MKMapView,它有许多注释.选择引脚会显示标注,按下附件会将新的视图控制器弹出到堆栈中.但是,当我从新的VC按回来时,标注仍然打开.我怎么关闭它?
我试过了
if([[myMapView selectedAnnotations] count] > 0)
{
//deselect that annotation
[myMapView deselectAnnotation:[[myMapView selectedAnnotations] objectAtIndex:0] animated:NO];
}
Run Code Online (Sandbox Code Playgroud)
但这不起作用.selectedAnnotations在数组中只有一个条目,因此它会进入此语句,但不会关闭标注.
我是否需要在MKAnnotation实现或MKPinAnnotationView中添加内容?
小智 36
selectedAnnotations中的对象是MKAnnotation的实例
NSArray *selectedAnnotations = mapView.selectedAnnotations;
for(id annotation in selectedAnnotations) {
[mapView deselectAnnotation:annotation animated:NO];
}
Run Code Online (Sandbox Code Playgroud)
lev*_*han 13
如果您想坚持使用地图工具包文档.
for (NSObject<MKAnnotation> *annotation in [mapView selectedAnnotations]) {
[mapView deselectAnnotation:(id <MKAnnotation>)annotation animated:NO];
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
13077 次 |
最近记录: |