我在视图中有我的UIImageView,它将从服务器下载图像,在下载完成后,我的UIImageView高度将根据图像的高度进行调整,但问题是它在iOS8中完美运行,但在iOS7中没有。在iOS7中,高度比我试图设置的要大得多。我通过IB设置autolayout
以下是我的代码摘录(默认为250)
if(image.size.height<250) headerView.itemImageView.contentMode = UIViewContentModeCenter;
else{
adjustedHeight = image.size.height*320.0f/image.size.width;
imageHeight = adjustedHeight;
[headerView.heightContraintLayout setConstant:adjustedHeight];
[headerView.itemImageView layoutIfNeeded];
//after this line of code, I check the size of itemImageView is extended more than the adjestedHeight that I set in the previous line ( this only happened in iOS7 not iOS8
答案 0 :(得分:0)
您将图片视图的内容模式设置为“中心”。
根据您需要实现的目标,尝试将其设置为“Aspect Fill”或“Scale to Fill”。