当用户平移地图时,iOS 6中的地图注释不会保持旋转状态 [英] Map Annotations in iOS 6 don't stay rotated when user pans the map

查看:104
本文介绍了当用户平移地图时,iOS 6中的地图注释不会保持旋转状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

非常喜欢这个问题的答案 https://devforums.apple.com/message/723468 。我不能发布详细信息,因为它关于iOS 6并且是每个Apple的机密。

Would really love an answer to this question https://devforums.apple.com/message/723468. I can't post the details because its about iOS 6 and is Confidential per Apple.

请将答案/评论发布到Apple Dev论坛帖子并让我知道在这里。

Please post the answers/comments to the Apple Dev forums post and let me know about it here.

编辑:自iOS6正式发布以来:

在我的pre-ios6代码我这样做是为了在用户位置移动时旋转地图:

In my pre-ios6 code I'm doing this to rotate the map when the user location moves:

//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个用户)。

And this worked fine (1000s of users).

然而,在ios6中(我在2012年9月4日更新了Xcode / sdk),注释视图不保持此轮换(例如,如果地图被淘汰)。它们翻转回到非旋转状态(由于我的地图旋转意味着它们以一定角度而不是水平显示文字)。

In ios6 however (I updated Xcode/sdk on 9/4/2012), the annotation views do not maintain this rotation (for example if map is panned). They flip back to their non rotated state (which, since my map is rotated means they show text at an angle instead of horizontal).

代码会暂时旋转注释因此他们的文本显示为水平,但如果地图被平移(并且它们似乎也是其他原因)那么注释会翻转到非旋转状态,我的注释文本会以相对于旋转地图的角度显示。

The code does temporarily rotate the annotations so their text appears horizontal, but if map is panned (and their seem to be other causes as well) then the annotations flip to their non-rotated state and my annotation text appears at an angle relative to the rotated map.

旋转MKAnnotationView以使其在IOS6中保持旋转的正确方法是什么?导致更改的MKMapView中发生了哪些变化?

What is the correct way to rotate an MKAnnotationView so that it stays rotated in IOS6? What has changed in MKMapView that caused the change?

推荐答案

对此的修复是在viewForAnnotation方法中执行以下操作: / p>

The fix for this is to do the following in the viewForAnnotation method:

// iOS6 BUG WORKAROUND !!!!!!!
if (is6orMore) {
     [annotationView setTransform:CGAffineTransformMakeRotation(.001)]; //any small positive rotation
}

这是我在评论中发表的评论原始问题然后由cristis发布作为答案(引用我的评论),但我发布并接受我自己的答案,因为我想出了它。这有意义吗?

This was posted as a comment by me in the original question and then posted by cristis as an answer (referencing my comment), but I'm posting and accepting my own answer since it was me that came up with it. Did that make sense?

这篇关于当用户平移地图时,iOS 6中的地图注释不会保持旋转状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆