Monotouch MapKit - 注释 - 添加按钮到气泡
有人知道是否有办法在注释上添加按钮吗?
我希望该位置是可选择的 - 所以你可以说..选择该位置并通过单击按钮获取该位置的所有事件。
这可能吗?
w://
Anyone know if there's anyway to get a button onto an annotation?
I'd like the location to be selectable - so you can say.. select the location and get all the events at that location by clicking on the button.
is this possible?
w://
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是我用于注释的代码,它在气泡右侧包含一个按钮。您可以设置 IBAction 将新视图推送到堆栈上以显示您想要的任何内容
Here's the code I used for my annotation, it includes a button on the right side of the bubble. You can set an IBAction to push a new view onto the stack to display whatever you want
我刚刚在 Objective C 中帮助了其他人,但我确信这个概念与 Mono 是相同的。您需要创建一个自定义 MKAnnotationView 对象并覆盖 MKMapViewDelegate 类的 GetViewForAnnotation (obj-c 中的 viewForAnnotation)方法... 查看其他问题。
当您创建自定义 MKAnnotationView 对象时,它基本上是一个用于地图注释的 UIView...您只需将按钮和其他信息添加到视图中,当用户点击注释时它将显示。
这里是委托方法的一些粗略代码:
I just helped someone else with this in objective c, but I'm sure the concept is the same with mono. You need to create a custom MKAnnotationView object and override the GetViewForAnnotation (viewForAnnotation in obj-c) method of your MKMapViewDelegate class... check out the other question.
When you create your custom MKAnnotationView object it is basically a UIView made for map annotations... you can just add your button and other info to the view and it will show up when the user hits the annotation.
Here some rough code for the delegate method: