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 *)view
in your MapView delegate.
The MKAnnotationView
contains a property annotation
.
精彩评论