【发布时间】:2012-09-07 20:13:29
【问题描述】:
真的很想回答这个问题https://devforums.apple.com/message/723468。我无法发布详细信息,因为它是关于 iOS 6 并且是 Apple 的机密信息。
请将答案/cmets 发布到 Apple Dev 论坛帖子并在此处让我知道。
编辑:由于 iOS6 正式发布:
在我的 ios6 之前的代码中,我这样做是为了在用户位置移动时旋转地图:
//this is in my MKMapViewDelegate
-(void) rotateMap:(MKMapView *)mapViewTmp forLocation:(MKUserLocation *) userLocation {
...
//calculate needed rotation
...
[mapViewTmp setTransform:CGAffineTransformMakeRotation(lastRotation)]; //rotate the MKMapView
for (id<MKAnnotation> annotation in mapViewTmp.annotations) {
MKAnnotationView* annotationView =[mapViewTmp viewForAnnotation:annotation];
[annotationView setTransform:CGAffineTransformMakeRotation(-lastRotation)]; //counter rotate the Annotation Views
[annotationView setNeedsDisplay]; //ios6
}
}
这很好用(1000 多个用户)。
然而,在 ios6 中(我在 2012 年 9 月 4 日更新了 Xcode/sdk),注释视图不保持这种旋转(例如,如果地图被平移)。它们会翻转回未旋转的状态(由于我的地图是旋转的,这意味着它们以一定角度而不是水平显示文本)。
代码确实会暂时旋转注释,使其文本显示为水平,但如果地图被平移(并且它们似乎也是其他原因),那么注释会翻转到它们的非旋转状态并且我的注释文本会出现在一个角度相对于旋转的地图。
旋转 MKAnnotationView 以使其在 IOS6 中保持旋转的正确方法是什么? MKMapView 发生了什么变化导致了这种变化?
【问题讨论】:
-
如果您因为保密协议而无法在问题中发布详细信息,我们将如何在答案中发布详细信息? :)
-
在 Apple Dev 论坛中发布详细信息。您可以在此处发布答案,如果您想要答案的堆栈点,只需说“查看我发布的回复”即可。
-
我看到了完全相同的问题。当用户平移或缩放图像时,我应用于 MKAnnotationView 对象的转换被删除。我已经向 Apple Dev 提交了错误报告并回复了您的论坛帖子。如果/当我找到答案时,我会告诉你。重大回归,我从 iOS 3.0 开始就成功了。
-
不幸的是,在最初的测试版令人兴奋之后,Apple 开发者论坛可能会变得非常风滚草。
-
并且修复方法是===>在 viewForAnnotation 方法中: if(is6orMore) { [annotationView setTransform:CGAffineTransformMakeRotation(.001)]; //iOS6 BUG 解决方法!!!!!!! }