iPhone MapKit:注释图像重置回图钉

发布于 2024-08-18 10:10:11 字数 380 浏览 5 评论 0原文

我向 MapView 添加了多个注释,并使用自定义图像而不是默认图钉。我正在使用 viewForAnnotation 委托方法来设置自定义图像,如下所示:

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

我也尝试过:

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

现在,这些都可以很好地设置图像。但是,当点击注释或 mapType 更改为 Satellite 或 Hybrid 时,它会重置回红色图钉图像。我缺少什么?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

苏别ゝ 2024-08-25 10:10:11

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

Don't use MKPinAnnotationView - just use MKAnnotationView.

舂唻埖巳落 2024-08-25 10:10:11

我想我明白了。我最终不得不子类化 MKAnnotationView。

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

剩余の解释 2024-08-25 10:10:11
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;
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;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文