Default.png and Landscape Mode

In a previous post I showed how to start your application in landscape mode. One aspect that I didn’t cover, and has since come up in an application prototype, is how to get Default.png to cooperate such that it is shown with its content properly oriented as well.

My original inclination was to create Default.png to be 480w x 320h, seems logical, however, I’ve since learned that Default.png must be 320w x480h. Therefore you need to create Default.png as 320×480 and properly rotate the contents to match the landscape device orientation you are after.

Here’s the complete process:

Step 1 – Set UIInterfaceOrientation key in the info.plist file to UIInterfaceOrientationLandscapeLeft (iPhone home button will be on the left) or UIInterfaceOrientationLandscapeRight (home button on right).

Step 2 – Create Default.png file to be 320w x 480h. Rotate the content inside the png file to match the orientation you set in the plist file. For example, if you choose UIInterfaceOrientationLandscapeRight, rotate the content in Default.png 90 degrees clockwise.

For example, the resulting Default.png should be oriented as shown below for a info.plist setting of UIInterfaceOrientationLandscapeRight.

Step 3 – For views to be shown in landscape mode, manually rotate the coordinate system 90 degrees clockwise or counter-clockwise depending on the orientation set in your plist file. For example, the code below rotates properly for the landscape right orientation.

- (void)viewDidLoad
  self.view.transform = CGAffineTransformIdentity;
  self.view.transform = CGAffineTransformMakeRotation((M_PI * (90) / 180.0)); 
  self.view.bounds = CGRectMake(0.0, 0.0, 480, 320);

Thanks to Felipe Oliveira and Ted Oliverio who provided insight about the requirements and formatting of the Default.png file.