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?
Asked
Active
Viewed 3,658 times
2 Answers
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
-
2I did this but my app still allows one of the Portrait mode. How come? This happens on iOS 5.1, but on iOS 6.0 it's perfect. – Van Du Tran Jan 22 '13 at 19:49
-
Just to clarify, this chunk of code goes in each view controller. – capikaw Feb 14 '13 at 22:46
0
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);

Hardik Mamtora
- 96
- 1