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:]: unrecognized selector sent to instance. I use a number of annotations classes (MKPinAnnotationView and MKAnnotationView). May be this error occurred because I use the dequeueReusableAnnotationViewWithIdentifier.

Voloda2
  • 12,359
  • 18
  • 80
  • 130

1 Answers1

3

You should assign different identifiers for both types of annotation views. Otherwise, you will end with MKPinAnnotationView where just an MKAnnotationView is expected and vice versa (which you've experienced here).

Deepak Danduprolu
  • 44,595
  • 12
  • 101
  • 105