2

So I've already tried setting the Supported Interface Orientations key in my iPad app's Info.plist to support both landscape modes. However when I put my iPad in a portrait orientation, my screen rotates. Because of the way my app is designed I only want my app to display itself in either landscape modes, how can I do that?

Christian Gossain
  • 5,942
  • 12
  • 53
  • 85

2 Answers2

12

Setting the Info.plist key is mainly used for determining the orientation of your app at startup. If your view controllers return YES for a given orientation from shouldAutorotateToInterfaceOrientation:, the interface will be allowed to orient itself that way, regardless of what the Info.plist says. The solution is to only allow landscape orientations in that method:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation
{
    return UIInterfaceOrientationIsLandscape(orientation);
}
Justin Spahr-Summers
  • 16,893
  • 2
  • 61
  • 79
0

return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);