2010-05-31 5 views
0

Un suivi à cette quesiton:Retrait, puis en ajoutant MKAnnotations à un MapView me laisse avec un MapView blanc

Forcing Reload of View when returning from FlipSideView of Utility Application

Lors du retour de la vue Flipside, j'appelle

NSArray *annotations = [NSArray arrayWithArray:[mapView annotations]]; 
[mapView removeAnnotations:annotations]; 

Pour supprimer toutes les broches de la carte (laissez-moi savoir si ce n'est pas la meilleure façon de le faire).

Puis:

for(Hole *hole in fetchedObjects) 
    { 
     double latitude = [hole.Latitude doubleValue]; 
     cord.latitude = latitude; 
     double longitude = [hole.Longitude doubleValue]; 
     cord.longitude = longitude; 

     WellPlaceMark *placemark = [[WellPlaceMark alloc] initWithCoordinate:cord withWellType:[NSString stringWithString: hole.WellType]]; 
     [mapView addAnnotation:placemark]; 

    } 

Plus:

- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{ 
    MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"]; 

    if ([annotation isKindOfClass:[MKUserLocation class]]) 
     return nil; 

    if([annotation isKindOfClass:[WellPlaceMark class]]) 
    { 
... 

    } 
    annView.animatesDrop=FALSE; 
    return annView; 
} 

Tout ce code semble être appelé dans le débogueur, mais quand il est fini, je suis présenté avec une carte vierge. J'ai essayé de faire un zoom arrière et les broches ne sont nulle part. La carte se charge bien au premier essai, mais une fois que j'appelle removeAnnotations, ils ne reviennent jamais.

Répondre

0

Je l'ai compris: J'ajoutais un nouveau MKMapView à l'index 0, qui apparaissait sous le MKMapView que j'avais effacé. Ré-utiliser le même MKMapView a résolu le problème.