This error doesn\'t make sense, as the preferred orientation UIInterfaceOrientationLandscapeRight
is returned by the supported orientation
//iOS
Those are the wrong enums for supportedInterfaceOrientations
. You need to use UIInterfaceOrientationMaskLandscapeLeft
, etc (note the word mask in the middle)
from the documentation:
-(NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskLandscapeLeft;
}
Note that the correct orientation is "Mask"! Did you try this?
Your code should look like this:
-(BOOL)shouldAutorotate
{
return NO;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeRight;
}
Also, make sure in your Info.plist
you have set the correct orientations for you app because what you return from supportedInterfaceOrientations
is intersected with the Info.plist
and if it can't find a common one then you'll get that error.
supportedInterfaceOrientations is only called, if shouldAutorotate is set to YES
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeRight;
}
The easiest approach for me, is only to set the Info.plist
If you like to support iOS 5 use this code in your view controllers.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}