O'Reilly logo

iOS Programming: The Big Nerd Ranch Guide by Joe Conway, Aaron Hillegass

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required