Clarence
Clarence

Reputation: 1943

Force landscape mode at the beginning of app, but allow later changes in orientation

I am planning to allow user to rotate the devices however during launch, i want the app start from landscape mode. May i know how can i do that?

Here is my code now for the orientation

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
        return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
    } else {
        return YES;
    }
}

Upvotes: 2

Views: 1032

Answers (2)

neeraj
neeraj

Reputation: 1221

In the Project settings/target settings (the blue icon towards the top of the navigation bar on the left, in xcode), there are settings for specifying the orientation. You'll see 4 images, each of which can be selected or deselected. Select only the one that you want initially for your app, and then you can use the shouldAutorotate and supportedInterfaceOrientation methods to allow or disallow certain orientations.
Supported interface orientations are also specified in the plist. Makes sure to keep the initial orientation for the app at the top of that supoortedInterfaceOrientations list in the plist file.

Upvotes: 1

IronManGill
IronManGill

Reputation: 7226

You need to check the orientation of the status bar.

Please check the following links :-

Force iOS app to launch in landscape mode

Modal View Controller force Landscape orientation in iOS 6

Force Landscape Orientation on iOS 6 in Objective-C

Upvotes: 2

Related Questions