20

With the introduction of Xcode 6, Apple removed the ability to easily have multiple storyboards for iPad and iPhone in Universal apps. Due to this, you cannot differentiate between iPad and iPhone on the rotation panel/settings.

How can i stop the iPhone app from Rotating into landscape, while still allowing the iPad app to do so.

Is it something you can only do in code? If it is, I am still using Objective C, not Swift.

InfinityLoop
  • 429
  • 3
  • 15

3 Answers3

55

Remove all the other answers' code. Go to your info.plist file and add the following.

  • "Supported Interface Orientations" - Array
    • "Portrait (bottom home button)" - String
    • "Portrait (top home button)" - String
  • "Supported Interface Orientations (iPad)" - Array
    • "Portrait (bottom home button)" - String
    • "Portrait (top home button)" - String
    • "Landscape (left home button)" - String
    • "Landscape (right home button)" - String
gjsalot
  • 768
  • 7
  • 5
2

Check out THIS answer.

Basically you'd have to implement Chris1994's answer on a UINavigationController or UITabBarController subclass and then add the following to the first UIVIewController subclass you have on that Nav or Tab Controller :

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}
Community
  • 1
  • 1
Benjamin
  • 8,128
  • 3
  • 34
  • 45
0
    - (NSUInteger) supportedInterfaceOrientations
    {
        NSString *device = [UIDevice currentDevice].model;

        if([device isEqualToString:@"iPhone"])
        {
            return UIInterfaceOrientationMaskPortrait;
        }
        else
        {
        return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscape;
        }
    }

- (BOOL)shouldAutorotate
{
if([device isEqualToString:@"iPhone"])
  {
     return NO;
  }
  else
  {
      return YES;
  }
}
Chris1994
  • 93
  • 6
  • The build fails due to an unknown receiver - 'device'. I have placed this in the ViewController.m file. Is this correct? – InfinityLoop Aug 26 '14 at 20:05
  • @WillWoodruff Yeah,but sorry there is a mistake copy NSString *device = [UIDevice currentDevice].model; into the bool should rotate – Chris1994 Aug 26 '14 at 20:17
  • While the code provided no longer produces any errors, it still fails to stop rotation, Any Ideas? – InfinityLoop Aug 27 '14 at 09:55