打开时的 MapView 注释标注操作
我有一个带有几个注释的地图视图。每个注释都有一个 leftCalloutAccessoryView,它是一个 UIViewController 类。这样做的原因是我希望每个注释从服务器加载一些数据,并将该数据的结果添加到注释 subTitle 中。 这一切都很完美,除了我不想在应用程序启动时加载所有数据,但我希望仅在标注气泡打开时才完成远程调用。
有人知道我该怎么做吗? viewWillload、viewDidLoad 等。在这种情况下不起作用。还有例子吗?
I have a mapview with several annotations. Every annotation has a leftCalloutAccessoryView which is a UIViewController class. The reason for this is that I want every annotation to load some data from the server, and add the result of that data to the annotation subTitle.
This all works perfectly, except that I don't want to load all that data when my app is started, but I want to the remote call to be done only when the callout bubble is opened.
Does anybody know how I can do this? The viewWillload, viewDidLoad ect. don't work in this case. Any examples as well?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我解决了添加观察者的问题。然后观察者做它的事情,然后标注就会出现。
我遇到的问题是,在显示气泡后,我无法更新标注气泡中的信息。做到这一点的唯一方法是创建自己的标注气泡(据我所知),考虑到我有最后期限,我不喜欢这样做。
我通过添加一个额外的 UIView 来解决这个问题,上面有一个 alpha 和一个文本“获取位置数据...”。我只是在按下某个位置时显示该视图,当观察者完成时,我再次隐藏该视图(当然是使用动画)。
希望我的回答对其他人有帮助。
代码:
更多代码:
并将其放在 @synthesize 之后:
I solved the issue adding an observer. The observer then does its thing and after that the callout shows up.
Something I had problems with is that I couldn't update the information in the callout bubble after the bubble is shown. The only way to do this is to create your own callout bubble (as I understand it), which is something I didn't feel like given that I have a deadline.
I fixed that by adding an extra UIView with an alpha on it and a text "Getting location data...". I just show up that view when pressing an location and when the observer is done, I hide the view again (off course by using an animation).
Hope my answer helped others.
Code:
Some more code:
And put this just after the @synthesize's: