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?

4

3 回答 3

18

不要使用 MKPinAnnotationView - 只需使用 MKAnnotationView。

于 2010-11-01T15:07:06.603 回答
3

我想我明白了。我最终不得不继承 MKAnnotationView。

于 2010-01-18T18:43:48.467 回答
0
MKAnnotationView* pinView = [[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:AnnotationIdentifier] autorelease];

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

不要给MKPinAnnotation它默认的 pin 注释。仅使用MKAnnotationView对象而不使用:

pinView.animatesDrop=YES;
于 2012-05-16T11:57:08.457 回答