Autolayout for Height working in iOS8 but not working in iOS7

百般思念 提交于 2019-12-25 06:59:00

问题


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. In iOS7, the height is scaled to much more than I tried to set. I am setting autolayout via IB

Here is the excerpt from my code (default is 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

回答1:


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.



来源:https://stackoverflow.com/questions/31889762/autolayout-for-height-working-in-ios8-but-not-working-in-ios7

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