【发布时间】:2015-01-16 20:22:15
【问题描述】:
我在一个旧项目的 VC 中得到以下代码(没有故事板,纯代码):
- (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
}
如果我评论最后一行,从纵向到横向或其他方式的旋转大约是 3 秒 在 ios8 下!此外,偶尔会出现无法分配渲染缓冲区存储!错误。
如果我不评论它,它几乎是瞬时的(0.7 秒)。 它似乎只与地图视图有关,其他视图/VC 旋转就好了。
在 ios7 下,无论是否注释该行,在任何情况下旋转都很快。
为什么?为什么只有地图视图受到影响?
编辑: 显然自动调整掩码是错误的。如果在viewDidLoad 中我将它的值设置为none 并在willRotate 中手动更改框架,它的工作速度很快。
【问题讨论】:
标签: ios ios7 ios8 mkmapview autoresizingmask