当 MKMapView 中的 MKAnnotation(Pin) 触摸/按下/单击时显示 TableView
我想在有人触摸某个图钉时显示该图钉的大量人口统计数据,因此提供弹出窗口并不能解决这个问题。我想一旦触碰了引脚,我只需将 tableviewController 粘贴到 NavigationController 上,表视图将可以访问该对象并显示单个对象信息,每行一个项目和 1 个部分。
无论如何,我很难弄清楚 MKMapViewDelegates 方法,因为它们似乎都没有做我需要的事情和/或允许我返回表视图或将该视图推送到导航控制器上。
我尝试过:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation;
但这需要返回 MKAnnotationView,我真的只需要这个方法通过向用户显示所有数据的表格视图来工作。我希望有一些简单的东西,比如 userDidTouchPin 方法......
有人知道如何完成我想做的事情吗?
I want to display quite a bit of demographic data for a certain pin when someone touches on it, so providing a pop-up isn't going to cut it. I figured once the pin is touched I will just stick a tableviewController onto the NavigationController and the table view will have access to the object and display the single objects information, with one item per row and 1 section.
Anyway I'm having a hard time figuring out MKMapViewDelegates methods as it appears none of them do what I need and/or allow me to return a tableview or push that view onto the navigation controller.
I played around with:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation;
But that requires a MKAnnotationView be returned and I really just need this method to work by showing the user a table view of all the data. I was hoping for something simple like a userDidTouchPin method....
Anyone have any ideas how to accomplish what I am trying to do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想在用户选择图钉(而不是其标注上的按钮)时执行某些操作,请实现
mapView:didSelectAnnotationView:
委托方法并在那里呈现或推送您的详细视图控制器。选定的注释对象可用作
view
参数的annotation
属性:您可能需要检查选择了哪种类型的注释(例如,如果选择了 MKUserLocation 则不执行任何操作,等),您可能需要将 view.annotation 转换为您自己的注释类,以轻松访问您可能拥有的任何自定义属性。
If you want to do something when the user selects the pin (and not a button on its callout), then implement the
mapView:didSelectAnnotationView:
delegate method and present or push your detail view controller there.The selected annotation object is available as the
annotation
property of theview
parameter:You might need to check which type of annotation was selected (eg. if MKUserLocation was selected do nothing, etc) and you might need to cast the view.annotation to your own annotation class to easily access any custom properties you may have.