Question

I have a problem that I can't understand resizing views. My deployment target is iOS 5.0, so I have disabled auto layout in the interface builder to make it compatible with iOS 5.0. The view does not resize automatically. Following is an example:

Interface Builder Snapshot:

enter image description here

4-inch screen:

enter image description here

3.5-inch screen (has problem):

enter image description here

As you can see, the button at the bottom of the view goes out of the screen. The background image also does not resize automatically. I can not understand how I can solve this problem. Can anyone help me?

Was it helpful?

Solution

Welcome to the pre-autolayout world! You must set the autoresizing "springs and struts" so that the stuff at the bottom is attached to the bottom of the superview and not the top. So, struts to the bottom, springs to the top. That way, as the superview gets larger and smaller, the stuff at the bottom moves with the bottom.

You could alternatively reposition the stuff in code, but there's no need in this situation.

Here's the section on autoresizing from my book:

http://www.apeth.com/iOSBook/ch14.html#_autoresizing

The part about the superview and the background image not being resized is a different matter. Is this the view of a UIViewController? If so, then if you are putting the UIViewController into the view controller parent-child hierarchy correctly, it will be resized by its parent. But you have not shown any code, so there's no telling what this view may be or how it is supposed to get into the interface.

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