I created a custom annotation to display my data. The data comes from moving vehicles and I've got to update their location on the map as well as their title (it shows the last update time).
My first approach was to simply remove all annotations and recreate them. However this leads to a lot of horrible flickering (the map clears, and then all annotations appear again) and the map blocks while it redraws. Less than optimal solution.
In the OS4 SDK they improved the MKMapViewAnnotation
and I can now set the coordinates (they were readonly before). Changing the coordinates moves the view nicely where it should be without any flickering. That solved one of my issues.
It said in the API documentation that changing the title of the MKAnnotation
will update the MKAnnotationView
. Indeed that's the case for the MKPinView
. If I update the MKAnnotation
's coordinates and title, the pin moves and shows the new data.
How can I achieve the same result using my custom MKAnnotationView
? I can't see any way to ask the view to refresh.
I tried calling setNeedsLayout
on the MKAnnotationView
but that only resulted in the view disappearing.
Cheers.