I only want to execute a method call when the user clicks on a annotation pin on the map. I read the Apple documentation but am still unsure of how I can do it (or if this is even possible).
For example, I have created a restaurant class with a ‘Distance from current location’ property and the instances are added to a mapview as annotations.
I only want to trigger the calculateDistance method when the user clicks on an annotation (and the callout view is displayed).
Is there any way of doing this?
Override
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)viewin your MapView delegate.The
MKAnnotationViewcontains a propertyannotation.