2011-05-24 53 views
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而发生此错误。[MKAnnotationView setAnimatesDrop:]:无法识别的选择器发送到实例。但为什么?

回答

3

您应该为这两种注释视图分配不同的标识符。否则,您将以MKPinAnnotationView结束,其中只需MKAnnotationView,反之亦然(您在此经历过)。

相关问题