1
(MKAnnotationView *) mapView:(MKMapView *)theMapView
             viewForAnnotation:(id <MKAnnotation>)annotation
{
    if ([annotation isKindOfClass: [MyLocation class] ])
    {
        MKPinAnnotationView *annotationView = (MKPinAnnotationView *) [theMapView dequeueReusableAnnotationViewWithIdentifier:placemarkIdentifier];
        if(annotationView == nil)
        {
            annotationView = [[MKPinAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:placemarkIdentifier];
        }
        else 
        {

            annotationView.annotation = annotation;         
        }

        annotationView.enabled = YES;
        annotationView.animatesDrop = NO;
        annotationView.pinColor = MKPinAnnotationColorPurple;
        annotationView.canShowCallout = YES;
        annotationView.draggable = YES;


       return annotationView;
    }
}

[MKAnnotationView setAnimatesDrop:]:无法识别的选择器发送到实例。我使用了许多注释类(MKPinAnnotationView 和 MKAnnotationView)。可能是因为我使用了 dequeueReusableAnnotationViewWithIdentifier 而发生了这个错误。

4

1 回答 1

3

您应该为两种类型的注释视图分配不同的标识符。否则,您将在预期的MKPinAnnotationView地方结束,MKAnnotationView反之亦然(您在这里经历过)。

于 2011-05-24T15:30:25.877 回答