Search code examples
iphoneiosios4mapkit

iOS: MKAnnotationViews are very slow to appear


I am adding 54 annotations to an MKMapView in a loop like this:

for (Item *item in items) {

    [mapView addAnnotation:item];       

}

I am logging when this completes and it never takes long, but there is a very long delay before the annotations appear on my map view. What is going on? How can I get the annotations to appear faster?

Update: the data set I am using is not small and I am holding it entirely in memory. I have noticed the occasional level 1 or 2 memory warning. Could this impact MKMapView performance?


Solution

  • There's nothing wrong with that code for adding annotations. The problem is probably somewhere else. Maybe you're getting the annotations from a web service. Maybe your annotation view objects are very large or complex.

    If you want to try a different approach, use addAnnotations: to add all annotations at once, but I don't think it will make a difference.