似乎可以更改用户位置注释图像。 也许有人可以看到我错在哪里......
-(MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation {
if ([annotation isKindOfClass:[MKUserLocation class]]) {
NSString* AnnotationIdentifier = @"Annotation";
MKAnnotationView *annoationView = [mapView dequeueReusableAnnotationViewWithIdentifier:AnnotationIdentifier];
[annoationView setImage:[UIImage imageNamed:@"melocation"] ];
return annoationView;
}
}
答案 0 :(得分:1)
您无法在无法出列时首次初始化注释:
-(MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation {
if ([annotation isKindOfClass:[MKUserLocation class]]) {
static NSString* const kAnnotationIdentifier = @"Annotation";
MKAnnotationView *annoationView = [mapView dequeueReusableAnnotationViewWithIdentifier:kAnnotationIdentifier];
if (!annoationView) {
annoationView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:kAnnotationIdentifier];
}
[annoationView setImage:[UIImage imageNamed:@"melocation"] ];
return annoationView;
}
return nil;
}