0
后随该quesiton:删除,然后添加MKAnnotations到MapView的离开了我一个空白的MapView
Forcing Reload of View when returning from FlipSideView of Utility Application
当从另一面视图返回,我打电话
NSArray *annotations = [NSArray arrayWithArray:[mapView annotations]];
[mapView removeAnnotations:annotations];
要从地图上删除所有的针脚(让我知道这是不是这样做的最佳方式)。
然后:
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];
}
加:
- (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;
}
所有这些代码似乎在调试器中调用,但它结束时,我看到一个空白的地图。我尝试缩小和引脚无处。第一次尝试的地图加载得很好,但一旦我打电话给removeAnnotations
,他们就再也没有回来。