我在MKMapView上有一个显示当前用户位置的移动注释。我为这个注释设置了自己的图像,我想旋转它,这样您就可以看到标题了。
在viewForAnnotation代表中,我有:
static NSString *planeIdentifier = @"Plane";
static NSString *stationIdentifier = @"Station";
NSString *identifier;
if([[annotation title] rangeOfString:@"Plane" options:NSLiteralSearch].location == NSNotFound) {
identifier = stationIdentifier;
}
else {
identifier = planeIdentifier;
}
MKAnnotationView *annotationView = (MKAnnotationView *) [aMapView dequeueReusableAnnotationViewWithIdentifier:identifier];
if (annotationView == nil) {
annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier];
} else {
annotationView.annotation = annotation;
}
annotationView.enabled = YES;
annotationView.canShowCallout = NO;
annotationView.image = [UIImage imageNamed:@"airPlane.png"];
return annotationView;调用实例方法的代码如下:
[planeAnnotation setCoordinate:planeCoordinate];
MKAnnotationView* planeView = [self mapView:mapView viewForAnnotation:planeAnnotation];
[planeView setTransform:CGAffineTransformMakeRotation([[[self modele] udpData] getValueFor:HDING_TRUE item:DYNAMICS]*(M_PI/180))];问题是标题从未更新,即图像从未旋转。
任何帮助都非常感谢!
编辑:我尝试为我在MKAnnotationView上的每个mapView设置一个自定义标识符(注释的标题)(几百个),但是我注意到annotationView总是为零,这意味着它实际上不会从它排出任何队列。我认为这就是为什么它不旋转的原因,因为我没有旋转我在地图上显示的MKAnnotationView。
发布于 2012-07-16 21:43:14
为了回答我的问题,问题在于我调用委托方法MKAnnotationView* planeView = [self mapView:mapView viewForAnnotation:planeAnnotation];,而不是在转换MKAnnotationView时调用实例方法MKAnnotationView* planeView = [mapView viewForAnnotation:planeAnnotation];。
https://stackoverflow.com/questions/11476296
复制相似问题