IPhone MapKit: annotation images get reset back to contacts

I add a few annotations to MapView and use a custom image instead of the standard contacts. I use the viewForAnnotation delegate viewForAnnotation to set up a custom image as follows:

 view.image = [UIImage imageNamed:@"placemark.png"]; 

And I also tried:

 [(MKPinAnnotationView *)view setImage:[UIImage imageNamed:@"placemark.png"]]; 

Now they both set the image just fine. But when the annotation is either knocked, or mapType changes to Satellite or Hybrid, it returns to the red pin image. What am I missing?

+4
source share
3 answers

Do not use MKPinAnnotationView - just use MKAnnotationView.

+18
source

I think I get it. In the end, I had to subclass MKAnnotationView.

+3
source
 MKAnnotationView* pinView = [[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:AnnotationIdentifier] autorelease]; pinView.animatesDrop=YES; pinView.canShowCallout=YES; pinView.image=[UIImage imageNamed:@"userMain.png"]; 

Do not specify MKPinAnnotation , it accepts the default annotation. Use only the MKAnnotationView object and do not use:

 pinView.animatesDrop=YES; 
0
source

All Articles