Comments in your code have an answer. Instead of using a custom method and calling addTarget, use the calloutAccessoryControlTapped method to display. In this method, you will get an annotation link containing an annotation link.
Remove the addTarget call and replace the showDetails method as follows:
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view
calloutAccessoryControlTapped:(UIControl *)control
{
MyAnnotationClass *annot = (MyAnnotationClass *)view.annotation;
}
source
share