tipycalFlow
tipycalFlow

Reputation: 7644

Different Launch orientations for iPad and iPhone?

I'm making a universal app and I was wondering if it is possible to set initial orientation to Landscape for iPad and Portrait for iPhone? Currently, I'm setting initial interface orientation in the info.plist file but it doesn't seem to have different options for iPad and iPhone . If it cannot be done through info.plist file then how to do it programmatically?

Upvotes: 1

Views: 1745

Answers (3)

tipycalFlow
tipycalFlow

Reputation: 7644

It looks like the initial interface orientation property conflicts with the supported orientations. I found the solution here, though.

Upvotes: 1

mhunturk
mhunturk

Reputation: 296

    UIDevice* thisDevice = [UIDevice currentDevice];
    if(thisDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad)
    {
        [[UIDevice currentDevice] setOrientation: UIInterfaceOrientationLandscapeRight];
    }
    else
    {
        [[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait];
    }

Upvotes: 0

rishi
rishi

Reputation: 11839

programatically you can do using following code -

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {

        if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
            return YES;
        } 

    }
    else {

        if (interfaceOrientation == UIInterfaceOrientationPortrait) {
            return YES;
        }
    }

return NO;

}

Upvotes: 1

Related Questions