Here you can use a bunch of different methods.
For example, you can save ivar for each annotationView and do this:
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control { if (view == myFirstAnnotationView) { //do something } if (view == mySecondAnnotationView) { //do something } if (view == myThirdAnnotationView) { //do something } }
Or you can use the tag value in the annotation view.
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control { if ([view.tag isEqualToString@ "one"]) { } if ([view.tag isEqualToString@ "two"]) { } }
Or you can subclass MKAnnotationView to add some kind of behavior to it.
- (void)mapView:(MKMapView *)mapView annotationView:(MyMKAnnotationViewSubclass *)view calloutAccessoryControlTapped:(UIControl *)control { [view doAMethodIMadeWhenISubclassed]; }
No, this is a complete solution, and it would be difficult to provide one without understanding your application and design, but all they have in common is changing the View annotation before adding it to the map to decide what to do after the delegate callback. Hope this leads you to the right path.
source share