2011-05-24 48 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,反之亦然(您在此經歷過)。

相關問題