Romejanic Romejanic - 1 year ago 69
iOS Question

Multiple View Controllers - iOS 7

I am try to develop an application involving text views. If I use the 4 inch size, it goes out of the screen on 3.5 inch devices. If I change the size to 3.5 inch, fix it and change it back to 4 inch, there is this big, ugly gap above the text view.

I think the solution to this problem is multiple view controllers. One for the 3.5 inch and one for the 4 inch. But how would I do this? I am using Xcode 5, developing for iOS 7 and testing on an iPhone 4.

Thanks,
Romejanic

Answer Source

You dont have to use two view controllers. All you need are some Auto Layout Constraints or autosizing mask to resize your view for different screen sizes. Below are some helpful links.

Tutorial about auto layouts:

Part 1: http://www.raywenderlich.com/20881/beginning-auto-layout-part-1-of-2

Part 2: http://www.raywenderlich.com/20897/beginning-auto-layout-part-2-of-2

Working with Constraints in Interface Builder https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/AutolayoutPG/WorkingwithConstraints/WorkingwithConstraints.html#//apple_ref/doc/uid/TP40010853-CH8-SW1

Apple Auto Layout Guide https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/AutolayoutPG/Introduction/Introduction.html

A similar question about how to set auto layout constraints for 4 and 3.5 inches screens Resize view with Auto Layout between 3.5 and 4 inch form factor

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download