开发者

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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜