I have an MKMapView with about 1000 MKPinAnnotationView's on-screen at the same time.
It has extremely slow scrolling performance.
I am attempting to dequeue my annotations views appropriately like so:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
static NSString *viewIdentifier = @"annotationView";
MKPinAnnotationView *annotationView = (MKPinAnnotationView *) [mapView dequeueReusableAnnotationViewWithIdentifier:viewIdentifier];
if (annotationView == nil) {
annotationView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:viewIdentifier] autorelease];
}
return annotationView;
}
However my annotation views are never reused! I have 1000 instances of MKPinAnnotationView on my map at the same time. I can't help but feel that this is contributing to the slow performance.
Is this the correct way to dequeue reusable annotation views? Are they not being reused because they are all on the same screen at the same time and hence require separate instances?
Any tips on speeding up scrolling performance with large numbers of on-screen pins?