UIImageView with contentMode AspectFit break Autolayout height in iOS7 but working properly in iOS8

413 views Asked by At

According to my previous question. Autolayout for Height working in iOS8 but not working in iOS7

I use UIImageView which will display the image from server once the download finished. I have autolayout constraint to define the height of UIImageView which I set via IB and has an outlet.

In my code, when I finished download the image I change the height of autolayout to match the height of my image. It works perfectly in iOS8 but in iOS7 which I tested via simulator always display the UIImageView height bigger than image size make the vertical area of top and bottom blank Please see the screenshot here

enter image description here

I totally don't understand. I didn't get any warning but the autolayout just didn't work to keep the UIImageView height in place to what I set it via [layoutConstraint setConstant:]

Please help

1

There are 1 answers

0
joakim On

In your other question 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.