开发者

iPhone MapKit: Annotation images get reset back to pins

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:[U开发者_StackOverflow中文版IImage 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?


Don't use MKPinAnnotationView - just use MKAnnotationView.


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


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;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜