4

I'm adding several annotations to a MapView and using a custom image instead of the default pins. I am using the viewForAnnotation delegate method to set the custom image like this:

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

And I've also tried:

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

Now, these both set the image just fine. But when an annotation is either tapped or the mapType changes to Satellite or Hybrid, it resets back to the red pin image. What am I missing?

Kevin Cupp
  • 497
  • 4
  • 10

3 Answers3

18

Don't use MKPinAnnotationView - just use MKAnnotationView.

Bill
  • 44,502
  • 24
  • 122
  • 213
3

I think I got it. I ended up having to subclass MKAnnotationView.

Kevin Cupp
  • 497
  • 4
  • 10
0
MKAnnotationView* pinView = [[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:AnnotationIdentifier] autorelease];

pinView.animatesDrop=YES;
pinView.canShowCallout=YES;
pinView.image=[UIImage imageNamed:@"userMain.png"];

Don't give MKPinAnnotation its takes default pin annotation. Use only MKAnnotationView object and don't use:

pinView.animatesDrop=YES;
Rob
  • 415,655
  • 72
  • 787
  • 1,044
Vikas Pandey
  • 550
  • 4
  • 13
  • I think the edit was to conform to the standard that differentiates code from narrative. Notice how your code is in Courier font, and your narrative isn't. – Rob Oct 20 '12 at 04:24