Map rotation horribly slow on ios8

有些话、适合烂在心里 提交于 2019-12-05 23:31:47

问题


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
}

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.

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.

Under ios7 the rotation is fast in any case with that line commented or not.

Why ? And why is only the mapview affected ?

Edit: 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.


回答1:


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...

cheers Paul



来源:https://stackoverflow.com/questions/27014770/map-rotation-horribly-slow-on-ios8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!