Graphics Programs Reference
In-Depth Information
Autorotation
Many applications rotate and resize all of their views when the user rotates the device. You
could implement this using
UIDevice
notifications, but it would be a lot of work. For-
tunately, you can use
autorotation
to simplify the process.
If the view on screen is controlled by a view controller, when the device is rotated, the view
controller is asked if it is okay to rotate the view. If the view controller agrees, the view is
resized and rotated. Its subviews are also resized and rotated.
You will need a
UIViewController
subclass to get this autorotating behavior. This
view controller's
view
will have subviews, so we will use the
UIViewController
template with a XIB file to create this class.
Select
File
→
New
→
New File...
. From the
iOS
section, select
Cocoa Touch
, choose the
Objective-C class
template, and click
Next
.
Figure 8.2 UIViewController template