views:

354

answers:

2

I have a MKAnnotationView being allocated with a DetailDisclosure button being displayed on the right side of the annotation. How would I go about knowing when a user clicked on the annotation button? This is what my code looks like right now -

UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
pinView.rightCalloutAccessoryView = rightButton;
pinView.animatesDrop = YES;

Is there a built in method to detect when a accessory view has been touched? I'm guessing it would be like the UITableView methods, but I can't find anything. Thanks for any help.

A: 

Implement mapView:annotationView:calloutAccessoryControlTapped: method in your MKMapViewDelegate.

Vladimir
How would I fetch which indexPath has been clicked on? I tried the .tag but didn't work
Raphael Caixeta
What is indexPath when you're using MKMapAnnotations? You can get annotation object associated with annotation view through view's annotation property.
Vladimir
I have multiple annotations layed out on the map and I just want to make sure that once the user hits one of them, I have a way to tell which one was hit appropriately.
Raphael Caixeta
see my previous comment - you can get annotation object from annotation view - 2nd parameter of delegate method you must implement
Vladimir
+2  A: 

You need some object to be set as your map view's delegate, and implement the MKMapViewDelegate protocol method -mapView:annotationView:calloutAccessoryControlTapped:.

Noah Witherspoon