Abin Baby
Abin Baby

Reputation: 606

Orientation lock for iPhone only

I have designed UI for my iOS app with wAny hRegular setting.

Now orientation works fine in iPad. But when app is running on iPhone, orientation gives a blank white screen.

Is there any way such that I can lock orientation in iPhones only and orientation is available for iPad?

Upvotes: 2

Views: 151

Answers (3)

Ghouse
Ghouse

Reputation: 3

You can do this from project settings, please find the screenshots
1. https://i.sstatic.net/Ln1ZE.png "iPhone settings"
2. https://i.sstatic.net/n6Dsq.png "iPad settings"

Upvotes: 0

Vizllx
Vizllx

Reputation: 9246

Yes @david"mArm"Ansermot is right, I have just added the code, for quick snap:-

- (BOOL)shouldAutorotate {
         UIDevice* thisDevice = [UIDevice currentDevice];
        if(thisDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad)
          {
             return YES;
          }
        return NO;
}
- (NSUInteger)supportedInterfaceOrientations {
    UIDevice* thisDevice = [UIDevice currentDevice];
    if(thisDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad)
          {
            return (UIInterfaceOrientationMaskAll);
           }
    return (UIInterfaceOrientationMaskPortrait);
}

Upvotes: 0

David Ansermot
David Ansermot

Reputation: 6112

You can use shouldAutorotate and supportedInterfaceOrientation UIViewController methods to lock the rotation on iPhone but not on iPad.

Simply return YES for iPad and NO for iPhone in shouldAutorotate, and you returns the allowed orientation for iPhone/iPad in supportedInterfaceOrientation.

Upvotes: 1

Related Questions