简体   繁体   English

高度的自动版式可在iOS8中使用,但不能在iOS7中使用

[英]Autolayout for Height working in iOS8 but not working in iOS7

I have my UIImageView in the view which will download image from server and after downloading finish then my UIImageView height will be adjusted according to height of image but the problem is it is working perfectly in iOS8 but not in iOS7. 我的视图中有UIImageView,它将从服务器下载图像,下载完成后,UIImageView的高度将根据图像的高度进行调整,但问题是它在iOS8中运行正常,但在iOS7中却无法正常运行。 In iOS7, the height is scaled to much more than I tried to set. 在iOS7中,高度被缩放到远远超过我尝试设置的高度。 I am setting autolayout via IB 我正在通过IB设置自动版式

Here is the excerpt from my code (default is 250) 这是我的代码的摘录(默认为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

You set the image view's content mode to "centre". 您将图像视图的内容模式设置为“中心”。

Try setting it to "Aspect Fill" or "Scale to Fill" according to what you need to achieve. 尝试根据需要实现的设置为“纵横填满”或“缩放填满”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM