Introduction Allow application to be used in either portrait or landscape mode and to change orientation at runtime if phone is rotated. You can configure to only support one orientation. Autorotate is specified in the view controller, so if the user rotate the phone, the view controller will be asked if it's OK to rotate to the new orientation, if the view controller responds in the affrimative, the application's window and views will be rotated, and the window and views will get resized to fit the new orientation.
How to Enale Autorotate There are 3 approaches to implement autorotate. For the 2nd and 3rd approach, you need to override methods from UIViewController in your view's controller class.
Set correct autosize attributes for all obects make up your UI
Manuall reposition the objects in your view when notified that your view is rotated
Design 2 different versions of your view in Interface Builder, one for portrait mode, and a seperat one for landscape mode.
Rorate using autosize attribute
Tell iPhone that our view supports autorotate - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { //Return YES for supported orientations return (interfaceOrientation == UIInterfaceOrientationPortrait); } When the phone is changed to the new orientation, this method is called on the active view controller. There are 4 defined orientations:
UIInterfaceOrientationPortrait
UIInterfaceOrientationPortraitUpsideDown //This orientation is discurraged, because if the phone rings while it is being up held upside down, the phone likely to remain upside down when it is answered.
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight
Set correct autosize attribute Make object in IB to get focus, then pres Command-3 to bring up the size inspector, on the inspector, you can set autosize attribute.
...
Reoperation Manually Move the objects on rotation.