【发布时间】:2012-06-12 16:43:31
【问题描述】:
我有课
@interface MyLocation : NSObject <MKAnnotation>
@property (copy) NSString *name;
@property (copy) NSString *address;
@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
@property (nonatomic, strong) UIImage *banner;
@property (nonatomic, strong) NSString *descr;
当我在地图上添加位置时,我想要该方法 - (MKAnnotationView*) mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation 显示横幅 .... 我该怎么做?
- (MKAnnotationView*) mapView:
(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
static NSString *identifier = @"MyLocation";
if ([annotation isKindOfClass:[MyLocation class]]) {
MKPinAnnotationView *annotationView = (MKPinAnnotationView*)
[mapView dequeueReusableAnnotationViewWithIdentifier:identifier];
if (annotationView == nil) {
annotationView = [[MKPinAnnotationView alloc]
initWithAnnotation:annotation reuseIdentifier:identifier];
} else {
annotationView.annotation = annotation;
}
annotationView.enabled = YES;
annotationView.canShowCallout = YES;
annotationView.image = [UIImage imageNamed:@"Image2.jpg"];
return annotationView;
}
return nil;
}
此方法更改所有注释引脚,但我需要为每个注释使用不同的图像。 感谢您的帮助!
【问题讨论】:
标签: ios mkmapview mkannotationview