根据 MapKit 注释标注单击在视图中加载数据
我有一张地图,其注释标注上有一个公开按钮,单击该按钮会显示详细视图。地图上的每个点都需要在详细视图中加载不同的数据 - 出于显而易见的原因,我不想为每个注释构建单独的视图,但我不确定执行此操作的最佳方法。
如何标记已单击哪个注释,以便我可以通过详细信息的视图控制器加载正确的数据?
I have a map with a disclosure button on the callout of it's annotations, which when clicked displays a detail view. Each point on the map needs to load up different data in the detail view - I dont want to build separate views for each annotation, for obvious reasons, but I am unsure of the best way to do this.
How do I flag which annotation has been clicked, so I can load the correct data through the detail's view controller?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在注释类中实现数据加载功能。为此,您需要在注释类中引用该数据。
您的注释类可以类似于
要获得标注触摸,您可以在实现 MKMapViewDelegate 的控制器中实现 calloutAccessaryControlTapped 函数。
该函数将类似于
Edit
initWithCooperative 的实现将类似于:
You can implement the data loading function in your annotation class. To do that you will need to have a reference to that data in your annotation class.
Your annotation class can be something like
To get the callout touch, you can implement calloutAccessaryControlTapped function in the controller where you implement MKMapViewDelegate.
The function will be something like
Edit
The implementation of initWithCoordinate will be something like: