我有一个视图>> subview mkmapview.
在那我想要显示图像....我目前的形象是这样的.
我希望像这样表现出来

我怎样才能做到这一点 ?如何在此anotation中添加图像.
您正在谈论的图像对应于MKAnnotationView的leftCalloutAccessoryView属性.
从文档中摘录:
leftCalloutAccessoryView要在标准标注气泡的左侧显示的视图.
您可以实现如下方法:
- (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;
}
Run Code Online (Sandbox Code Playgroud)
希望这有帮助,文森特
| 归档时间: |
|
| 查看次数: |
7683 次 |
| 最近记录: |