With no developer interaction you can have a view resize itself to support an orientation, in many cases this is fine, but what if you need to change the layout of your UI objects to better suit the new orientation?
Apples answer is to:
- Have two separate ViewControllers with xibs that reflect the desired layout.
- Designate a master ViewController, (recommended portrait).
- Subscribe to
beginGeneratingDeviceOrientationNotifications
- In the notification event method (master), check the orientation and either push or pop the slave ViewController as a modal.
At face value, if the layout contains a number of UITextFields, changing the orientation clears the fields (from the users point of view) suggesting that a field copy method is also needed in the notification event method. Unless there is an automated provision for this? (or an alternative pattern)
But what if you want to have some nice short-delayed UI frame translation animations?
Alternatively, rather than having two View controllers I have used CGAffineTransforms
to animate UI object frame changes (triggered on willRotateToInterfaceOrientation
) with the added bonus of looking sexy, but the code doesn't look very elegant.
Im unaware of any other solutions.
To get to the point: What is the most efficient and fastest, way to change UI object layouts on orientation events that preferably facilitates frame translation animation?
Luke