When a annotation is clicked how can I pass data to its view controller?
When an MKAnnotation is clicked I need to call a function in its view controller, and pass it two NSStrings contained 开发者_如何学运维in the annotation. How can I achieve this?
Just assign your view controller as the map view's delegate
and implement
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
MKAnnotationView
has an annotation
property that you can use to get your strings.
Probably the annotations are some kind of buttons? In this case, they are the sender of the action -> A reference to the clicked annotation is passed as argument to the called function!
精彩评论