ios8上的地图旋转速度非常慢 [英] Map rotation horribly slow on ios8
问题描述
我在旧项目的VC中获得了以下代码(没有故事板,纯代码):
I got the following code in a VC in an old project (no storyboard, pure code) :
- (void)viewDidLoad {
[super viewDidLoad];
self.mapView = [[MKMapView alloc] initWithFrame:CGRectInset(self.view.frame, 10, 10) ];
[self.view addSubview:self.mapView];
self.view.backgroundColor = [UIColor redColor];
self.mapView.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
self.view.translatesAutoresizingMaskIntoConstraints = NO; // <--- this line
}
如果我评论最后一行, ios8下从纵向到横向的旋转或其他方式约为 3秒 !!此外,偶尔会在随机时间无法分配渲染缓冲区存储!错误出现。
If I comment the last line, a rotation from portrait to landscape or the other way is about 3 seconds under ios8 !! Also, occasionally at random times Unable to allocate render buffer storage! errors appear.
如果我不评论它,它几乎是瞬间的(的0.7秒强>)。
似乎它只与mapviews相关,其他视图/ VC旋转得很好。
If I don't comment it, it's almost instantaneous (0.7seconds). It seems it is only related to mapviews, the other views/VCs rotate just fine.
在ios7下,无论如何在该行评论时旋转速度很快或不。
Under ios7 the rotation is fast in any case with that line commented or not.
为什么?为什么只有mapview受到影响?
Why ? And why is only the mapview affected ?
编辑:很明显autoresizingmask是错误的。如果在 viewDidLoad
中我将其值设置为none并手动更改willRotate中的帧,则它的工作速度很快。
It seems clearly the autoresizingmask is wrong. If in viewDidLoad
I set its value to none and manually change the frame in willRotate, it works fast.
推荐答案
当应用程序从后台返回时我遇到了同样的问题。它冻结了几秒钟,然后再次起作用。我使用了没有Autolayout的.xib文件。当我更新.xib文件并添加了Autolayout选项时,问题就消失了。我想出了这个想法,因为你写道,自动化是解决方案中的问题。也许这对其他人也有帮助...
I had the same problem when the application came back from the background. It froze a few seconds and then it worked again. I used a .xib file without Autolayout. When I updated the .xib file and added the Autolayout option the problem was gone. I came up with this idea because you wrote that autoresizing was the problem in your solution. Maybe this will help others too...
欢呼
Paul
cheers Paul
这篇关于ios8上的地图旋转速度非常慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!