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. Fortunately, 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 FileNewNew File.... From ...

Get iOS Programming: The Big Nerd Ranch Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.