gpt4 book ai didi

iphone - 如何在 map 图钉注释中显示图像?

转载 作者:行者123 更新时间:2023-12-03 19:32:13 25 4
gpt4 key购买 nike

我有一个 View >> subview mkmapview 。

因为我想显示图像。 ……我现在的形象是这样的。 alt text

我想像这样显示

alt text

我该怎么做?我如何在此注释中添加图像。

最佳答案

您正在讨论的图像对应于 MKAnnotationView 的 leftCalloutAccessoryView 属性。

摘自文档:

leftCalloutAccessoryView The view to display on the left side of the standard callout bubble.

您可以实现这样的方法:

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id )annotation {

MKAnnotationView* annotationView = nil;

MyAnnotation *myAnnotation = (MyAnnotation*) annotation;
NSString* identifier = @"Pin";
MKPinAnnotationView* annView = (MKPinAnnotationView*)[self.mapView dequeueReusableAnnotationViewWithIdentifier:identifier];

if(nil == annView) {
annView = [[[MKPinAnnotationView alloc] initWithAnnotation:myAnnotation reuseIdentifier:identifier] autorelease];
}

UIImageView *leftIconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"LeftIconImage.png"]];
annView.leftCalloutAccessoryView = leftIconView;

return annotationView;
}

希望这有帮助,文森特

关于iphone - 如何在 map 图钉注释中显示图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4759947/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com