I have a universal single view app which has a UINavigationBar
toolbar
at the bottom, then the UIViewController
view
takes up the rest of the space.
I usually do everything programmatically, so for the longest time I've been calculating the UIViewController's
view
frame
manually in loadView
, taking into account all of the components that a device could have i.e. home indicator height on new iPhone device, opaque status bar on old devices.
However, with all the new devices I'm finding this way to be inefficient and have thought about switching to a storyboard or xib. I've never really worked with these so I don't understand how it works. For instance, if I create a storyboard with the ViewController's view taking the entire size of the usable area, will this translate for all devices? Will it resize correctly when there's rotation?
In general I'm kind of wondering, what is the most elegant / efficient way to create an app where the UIViewController's
view
takes up the entire usable area of the screen on all devices, including when the phone rotates?
I usually do everything programmatically, so for the longest time I've been calculating the UIViewController's view frame manually in
loadView
There was never any need to do that; you can just delete that code. The navigation controller itself will give its child view controller's view the correct frame!
All you have to do is provide the child view controller's views subviews with correct positioning. And that is something you should be doing just by giving them autolayout constraints, so that they will be correctly arranged no matter what size the view controller's view ends up being. You can do that in code or through a storyboard; it makes no difference.
In general I'm kind of wondering, what is the most elegant / efficient way to create an app where the UIViewController's view takes up the entire usable area of the screen on all devices, including when the phone rotates?
The elegant efficient way is: do nothing. That is what already happens, automatically, with no input from you.