开发者

iOS: MKAnnotationViews are very slow to appear

开发者 https://www.devze.com 2023-03-07 12:29 出处:网络
I am adding 54 annotations to an MKMapView in a loop like this: for (Item *item in items) { [mapView addAnnotation:item];

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 i开发者_如何学运维mpact MKMapView performance?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号