Question

I'm building an app that has a UIImageView below the UINavigationBar as the following screenshot displays. screenshot

Before I set the autoresizing constraints, I logged the bounds size, and it says the size is 320x505 which is quite reasonable because the navigation bar and the status bar takes up 64 pts.

The constraints are like this before I set them up:

enter image description here

And later, I've added the "inner cross" part of the constraints like below, and this time, while logging the bounds size, it gave me 320x569, which takes status bar and navigation bar into account.

enter image description here

I'm pretty sure that the "real" size of UIImageView does not increase, because when I load a image, it simply displays the image just fine, there's no difference, but I'm not sure why this happens.

So my question is what leads to this and how to fix it?

Thanks in advance!

Was it helpful?

Solution

The first Autosizing mode sets (among others) Fixed Top Margin & Fixed Bottom Margin & Fixed Height. Basicly, you're telling the view to have the same margins to top and to bottom but not to modify its height, which is pretty impossible, so the interface builder will give priority to the bottom fixed spring.

The second case, having Fixed Top Margin & Fixed Bottom Margin & Flexible height, stretches your images on the whole content. If you haven't unchecked the view controller's option (Extend under top bars) the full content is 568(for 4inch device, which is your case) (on ios 7 if you have that option checked the viewcontroller's view's y origin is under the navigationbar & status bar , right in the very top corner).

If you uncheck the Extend under top bar option, the viewcontroller's view will begin from 64.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top