In Chapter 5 I said I would explain more about view rotation when the orientation changes.
One of the responsibilities of the
UIViewController class is to work with the application’s window to handle device rotation (also known as device orientation changes). Although the
UIViewController class itself already includes the functionality to animate the transition from the current orientation to the new one (which you can override if you need to lay out the view again for the new orientation), it must also communicate to the application window whether it in fact wants to support a particular orientation.
This communication is accomplished through the
should AutorotateToInterfaceOrientation: message, with the new orientation as a parameter, is sent to the view controller when the user rotates the device. If the view controller supports that orientation, it returns
YES; if it doesn’t, it returns
When you use the Master-Detail Application template to create your project, that template generates an
RTDetailViewController that supports all orientations on the iPad and almost all orientations on the iPhone (The exception for the iPhone is upside down.). Listing 8-5 shows what the template comes up with.
Listing 8-5: The Master-Detail Application Template’s shouldAutorotateToInterfaceOrientation: