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?
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: