Skip to content

February 8, 2012

Display your iPhone Application in Landscape

by noise

A short tutorial about how to Display your iPhone Application in Landscape is presented here.

Let’s say you want to run your iPhone application in Landscape mode. How you do that? Well, it’s really simple you must do the following two steps. Let’s say your iPhone app name is MyApp First, from Xcode, go to your Resources section and find file MyApp-info.plist. Right click on MyApp-Info.plist file from Resources and choose Open As -> Source Code File, then add the following XML tags right before closing tag:

[xml]
<key>UIInterfaceOrientation</key>
<string>UIInterfaceOrientationLandscapeLeft</string>
[/xml]

Go to Classes -> MyAppViewController.m file and uncomment:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

then make that function to return YES, instead of returning:

(interfaceOrientation == UIInterfaceOrientationPortrait);

Recompile your project and you have your app running in lanscape mode. So your shouldAutorotateToInterfaceOrientation method will look like this:

// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    // return (interfaceOrientation == UIInterfaceOrientationPortrait);
    return YES;
}

This tip helps you to Display your iPhone Application in Landscape.

There are lot of apps that work/look better in landscape mode so in many situations is better to Display your iPhone Application in Landscape rather than in picture mode.

Read more from Cocoa

Leave a Reply

required
required

Note: HTML is allowed. Your email address will never be published.

Subscribe to comments