如何检测触摸注释视图事件?

1 xcode

我在地图上有一些Annotationview.我只是想检测用户触摸它时发生的事件.我想出了使用观察者,我在viewForAnnotation委托方法中为每个注释视图添加了观察者.我认为它会很完美,但还是有问题.annotationview的"selected"属性会意外地更改其值.有人告诉我如何解决这个问题.谢谢!

Chr*_*ove 5

你应该看看MKMapViewDelegate有这个方法来实现:

-(void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
Run Code Online (Sandbox Code Playgroud)

请参阅apple的文档 http://developer.apple.com/library/ios/#documentation/MapKit/Reference/MKMapViewDelegate_Protocol/MKMapViewDelegate/MKMapViewDelegate.html