删除然后将MKAnnotations添加到MapView会让我看到一个空白的MapView

时间:2010-05-31 16:50:25

标签: iphone mapkit

这个问题的后续行动:

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,它们就永远不会返回。

1 个答案:

答案 0 :(得分:0)

我明白了:我在索引0处添加了一个新的MKMapView,它出现在我已清除的MKMapView下方。重新使用相同的MKMapView解决了这个问题。