0

What is the best way of achieving this? I'm using XIBs with universal size classes (same XIB for iphone and ipad) but I want to lock rotation for iphone only.

Tom S
  • 174
  • 14

2 Answers2

2

The list of possible orientations should be in the Info.plist file, you can define distinct values for Ipad and Iphone if you want. Take a look on the discussion below:

https://stackoverflow.com/a/24467576/3330421

Community
  • 1
  • 1
carantes
  • 197
  • 1
  • 9
1

Try this:

For versions less than iOS 6:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
        {
            return NO;
        }
        else
        {
            return YES;
        }
}

For iOS 6+

- (BOOL)shouldAutorotate
{
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
    {
        return NO;
    }
    else
    {
        return YES;
    }
}
Sujith Thankachan
  • 3,508
  • 2
  • 20
  • 25