Stepo
Stepo

Reputation: 1056

View Controller resize

How to change sizes of ViewController? I'm making simple app which uses deliberately two views, one for horizontal and one for vertical view. I was trying to resize it inspector-view but the fields are gray and unchangeable.

Upvotes: 0

Views: 2593

Answers (1)

Jonah
Jonah

Reputation: 17958

UIViewControllers are not responsible for setting the size of their root view. It is expected that the parent of the view controller's view (either the window or some container view controller) will adjust the view's size to fill the window, fit above the tab bar, or otherwise be appropriately positioned. Interface Builder therefore doesn't allow you to set misleading frame values on that view.

To swap view based on orientation I suggest adding two sub-views to your root view and using one for each orientation. Even then the size you set for them in Interface Builder is somewhat misleading; you'll be able to set the sizes you want more importantly you should set their autoresizing properties such that they expand/shrink to fill their parent view. That way your layout won't break when the height of the status bar changes or you add a container view controller.

Upvotes: 1

Related Questions