开发者

How do I add a button to the subtitle of an MkMapView custom annotation?

开发者 https://www.devze.com 2022-12-31 18:32 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消