Share on Google+Share on Google+

Orientation iPhone SDK

Advertisement
While developing the application in iPhone please keep in mind that landscape orientation is not possible in the case of TabBar application. Every time you need to hide the tabbar whenever orientation is changed from portrait to landscape.

Orientation iPhone SDK

In this tutorial we are going to show you how to set orientation in iPhone application.

While developing the application in iPhone please keep in mind that landscape orientation is not possible in the case of TabBar application. Every time you need to hide the tabbar whenever orientation is changed from portrait to landscape.

But certainly it's possible in navigation based application. So, in this example .. we are developing a navigation based application that is both portrait and landscape orientation enabled.

Steps
Create a new UINavigation based application, assign name to it and save the app.

Create a mutable array and add objects to it, and then call in then configure the cell with array object in cellForRowAtIndexPath.
It will allow you to show the array data on cell. But that's option you can check orientation without data as well.

Uncomment shouldAutorotateToInterfaceOrientation method in implementation file and "return YES;" as it sets the application in both portrait and landscape mode.

Build and test your application.. it must look alike the given images.


You can also set the landscape orientation for UIVIew, UIScrollView etc... method is same. But if you want your application to support only landscape mode then either you can change it from .plist by adding given lines to it...
<key>UIInterfaceOrientation</key>
<string>UIInterfaceOrientationLandscapeRight</string>

or
simply set
[setOrientation:UIInterfaceOrientationLandscapeRight]; in shouldAutorotateToInterfaceOrientation method. It will work.

Download the code

Advertisements

Posted on: April 26, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.