MKMapView laden alle annotation-Ansichten auf einmal (einschließlich jene, die außerhalb der aktuellen rect)

UPDATE

Sieht es aus wie dieses problem wurde ruhig fest in iOS 4.3. Bis zu diesem Punkt ist die Entfernung, wurde als "weit genug" für eine Anmerkung, um recycelt werden zu sein schien, Hunderte von Meilen, sogar, wenn gezoomt in sehr eng. Wenn Baue ich meine app mit dem iOS 4.3 SDK, Anmerkungen recycelt werden, basierend auf vernünftiger Grenzen.


Hat sonst noch jemand dieses problem? Hier ist der code:

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(WWMapAnnotation *)annotation {



//Only return an Annotation view for the placemarks. Ignore for the current location--the iPhone SDK will place a blue ball there.

NSLog(@"Request for annotation view");

if ([annotation isKindOfClass:[WWMapAnnotation class]]){



    MKPinAnnotationView *browse_map_annot_view = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:@"BrowseMapAnnot"];



    if (!browse_map_annot_view) {
        browse_map_annot_view = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"BrowseMapAnnot"] autorelease];
        NSLog(@"Creating new annotation view");
    } else {
        NSLog(@"Recycling annotation view");
        browse_map_annot_view.annotation = annotation;
    }

...

Sobald die Ansicht angezeigt wird, bekomme ich

2009-08-05 13:12:03.332 xxx[24308:20b] Request for annotation view
2009-08-05 13:12:03.333 xxx[24308:20b] Creating new annotation view
2009-08-05 13:12:03.333 xxx[24308:20b] Request for annotation view
2009-08-05 13:12:03.333 xxx[24308:20b] Creating new annotation view

und auf und auf, für jede annotation (~60), die ich Hinzugefügt habe. Die Karte (richtig) zeigt nur die zwei Anmerkungen in der aktuellen rect. Ich bin der Einstellung der region in viewDidLoad:

if (center_point.latitude == 0) {
    center_point.latitude = 35.785098;
    center_point.longitude = -78.669899;
}

if (map_span.latitudeDelta == 0) {
    map_span.latitudeDelta = .001;
    map_span.longitudeDelta = .001;
}

map_region.center = center_point;
map_region.span = map_span;

NSLog(@"Setting initial map center and region");

[browse_map_view setRegion:map_region animated:NO];

Den log-Eintrag für die region festgelegt wird, wird auf der Konsole ausgegeben, bevor alle annotation-Ansichten angefordert werden.

Hier das problem, dass da alle Anmerkungen werden in der beantragt wird, auf einmal, [mapView dequeueReusableAnnotationViewWithidentifier] tut nichts, da es einzigartige MKAnnotationViews für jede annotation auf der Karte. Dies führt zu Gedächtnis-Probleme für mich.

Ein mögliches Problem ist, dass diese Annotationen gruppiert sind und in einem ziemlich kleinen Raum (~1 Meile radius). Obwohl die Karte vergrößert wird ziemlich eng in der viewDidLoad - (breiten-und Längengrad delta .001), es immer noch lädt alle annotation-Ansichten auf einmal.

Dank...

InformationsquelleAutor jmans | 2009-08-11
Schreibe einen Kommentar