Tom*_*Tom 4 mapkit mkannotationview ios
我有一个非常简单的问题:如何检查地图上是否选择了MKAnnotation?
我看不到选中的(GET)属性.
我希望解决方案不是通过触发选定/取消选择的事件并将其结果存储在属性中并在需要时检查它们.必须有一个更直接的.
非常感谢!
利用MKMapView didSelectAnnotationView:
使用的委托方法可以获得事件MKAnnotation Selected
-(void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view {
// Annotation is your custom class that holds information about the annotation
if ([view.annotation isKindOfClass:[Annotation class]]) {
Annotation *annot = view.annotation;
NSInteger index = [self.arrayOfAnnotations indexOfObject:annot];
}
}
Run Code Online (Sandbox Code Playgroud)
希望它会对你有所帮助.
归档时间: |
|
查看次数: |
2931 次 |
最近记录: |