tags:

views:

148

answers:

1

A followup to this quesiton:

http://stackoverflow.com/questions/2944581/forcing-reload-of-view-when-returning-from-flipsideview-of-utility-application

When returning from the flipside view, I'm calling

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

To remove all the pins from the map (let me know if this isn't the best way to do this).

Then:

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;
}

All of this code seems to be called in the debugger, but when it's finished, I'm presented with a blank map. I've tried zooming out and the pins are nowhere. The map loads up fine on the first try, but once I call removeAnnotations, they never return.

A: 

I figured it out: I was adding a new MKMapView at index 0, which was appearing underneath the MKMapView I had cleared. Re-using the same MKMapView solved the problem.

Chris McCall