首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MKAnnotationView旋转

MKAnnotationView旋转
EN

Stack Overflow用户
提问于 2012-07-13 18:33:34
回答 1查看 1.9K关注 0票数 2

我在MKMapView上有一个显示当前用户位置的移动注释。我为这个注释设置了自己的图像,我想旋转它,这样您就可以看到标题了。

在viewForAnnotation代表中,我有:

代码语言:javascript
复制
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;

调用实例方法的代码如下:

代码语言:javascript
复制
[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。

EN

回答 1

Stack Overflow用户

发布于 2012-07-16 21:43:14

为了回答我的问题,问题在于我调用委托方法MKAnnotationView* planeView = [self mapView:mapView viewForAnnotation:planeAnnotation];,而不是在转换MKAnnotationView时调用实例方法MKAnnotationView* planeView = [mapView viewForAnnotation:planeAnnotation];

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11476296

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档