我有一个显示自定义单元格的视图表视图。如果设备处于横向模式,这些单元格有一个 UIImageView 需要缩放。
我将autoresizingMasktableView 设置为UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth,对我的自定义单元格和 UIImageView 做了同样的事情。
我的问题是autoresizingMaskUIImageView 的设置会更改视图的框架,而无需旋转任何设备。
这是我的 UIImageView 的初始化代码。
- (UIImageView *)bigImageView
{
if (!_bigImageView)
{
_bigImageView = [[UIImageView alloc] initWithFrame:(CGRect){2, [self.header getHeight], 272, 272}];
[_bigImageView setImage:[UIImage imageNamed:@"square.png"]];
[_bigImageView setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
[_bigImageView setBackgroundColor:[UIColor redColor]];
}
return _bigImageView;
}
宽度应为272但会自动更改为232。
预期的结果autoresizingMask 应该是:

但我得到:

这个比例不再被尊重。