如何向 MkMapView 自定义注释的副标题添加按钮?

发布于 2024-09-01 21:46:43 字数 119 浏览 5 评论 0原文

基本上我的程序在地图上显示许多注释。用户点击其中一个后,它会显示该位置的标题。如何在标题下添加一个按钮,该按钮将显示一个新窗口,其中包含有关该位置的更多信息?我还对屏幕底部的一个按钮感到满意,该按钮在选择一个位置之前呈灰色。

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 information 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦里泪两行 2024-09-08 21:46:43

在 viewForAnnotation 方法中,设置一个按钮作为标注辅助视图:

annotationView.canShowCallout = YES;
UIButton *button = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
annotationView.rightCalloutAccessoryView = button;

您可以使用 rightCalloutAccessoryView 或 leftCalloutAccessoryView,但 文档建议在右侧放置一个披露按钮。

响应 calloutAccessoryControlTapped 方法。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文