How to find which annotation send showDetails?

筅森魡賤 提交于 2019-11-27 05:39:41

The comments in your code have the answer. Instead of using a custom method and calling addTarget, use the map view's calloutAccessoryControlTapped delegate method. In this method, you will get a reference to the annotation view which contains a reference to the annotation.

Remove the call to addTarget and replace your "showDetails" method with:

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view 
    calloutAccessoryControlTapped:(UIControl *)control
{
    MyAnnotationClass *annot = (MyAnnotationClass *)view.annotation;
    //do something...
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!