I’m interested in having a UIViewController that supports all orientations and cleanly uses two xib files to set up its subviews.
One possibility seems to be to use NSBundle’s loadNibNamed: method to load a new view hierarchy at each rotation, but this seems inefficient, and could have unfortunate side effects. For example, after reloading from a nib file, all my views would lose their previous state, such as adding text to a text field, etc.
Is there a better way to do this?
After some more research, I was not able to find an elegant solution to this. Because re-loading elements from a xib file at each rotation seemed slow and eliminated any dynamic view-based data, I switched over to a code-based setup (i.e. no more xib files).
I decided to create a method like this:
This method is called from the
shouldAutorotateToInterfaceOrientation:method, and handed the new orientation.