我使用自定义图像进行mapkit注释.但是我在使用自定义图像时遇到的主要问题是,当缩小时,注释不在地图上的正确位置,并且只有在我一直向下放大时,它才会显示注释点在正确的位置.似乎当我使用常规引脚MKPinAnnotationView时,它正常工作,因为引脚位于正确的位置放大或缩小,提前感谢任何可以提供帮助的人.
我使用的代码如下:
- (MKAnnotationView *)mapView:(MKMapView *)aMapView viewForAnnotation:(id <MKAnnotation>)annotation
{
NSLog(@"welcome into the map view annotation");
if ([annotation isKindOfClass:[MKUserLocation class]])
return nil;
MKAnnotationView *pprMapNote = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"pprMapNote"];
pprMapNote.image = [UIImage imageNamed:[NSString stringWithFormat:@"GPS_note.png"]];
pprMapNote.canShowCallout = YES;
pprMapNote.centerOffset = CGPointMake(-21,-60);
pprMapNote.calloutOffset = CGPointMake(0, 0);
//[pprMapNote addSubview:pprMapNoteImg];
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[rightButton addTarget:self
action:@selector(showDetail)
forControlEvents:UIControlEventTouchUpInside];
pprMapNote.rightCalloutAccessoryView = rightButton;
//remember to write in conditional for the different icons that should be loaded based on location
UIImageView *pprNoteLocIcon = [[UIImageView alloc] …Run Code Online (Sandbox Code Playgroud)