How do I add a button to the subtitle of an MkMapView custom annotation?
Basically my program displays many annotations on a map. after the user clicks on one, It displays the title of the location. How can I add a button under the title that will display a new window with more i开发者_如何学JAVAnformation on the location? I would also be content with a button at the bottom of the screen that is greyed out until one location is selected.
In the viewForAnnotation method, set a button as the callout accessory view:
annotationView.canShowCallout = YES;
UIButton *button = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
annotationView.rightCalloutAccessoryView = button;
You can use rightCalloutAccessoryView or leftCalloutAccessoryView but the documentation recommends putting a disclosure button on the right.
Respond to the button press in the calloutAccessoryControlTapped method.
精彩评论