Removing and then adding MKAnnotations to a MapView is leaving me with a blank MapView
Posted
by Chris McCall
on Stack Overflow
See other posts from Stack Overflow
or by Chris McCall
Published on 2010-05-31T16:50:24Z
Indexed on
2010/05/31
16:53 UTC
Read the original article
Hit count: 645
A followup to this quesiton:
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.
© Stack Overflow or respective owner