This error doesn't make sense, as the preferred orientation UIInterfaceOrientationLandscapeRight
is returned by the supported orientation
//iOS6
-(BOOL)shouldAutorotate
{
return NO;
}
-(NSUInteger)supportedInterfaceOrientations
{
return (UIInterfaceOrientationLandscapeRight | UIInterfaceOrientationLandscapeLeft);
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeRight;
}
Error :
Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'preferredInterfaceOrientationForPresentation must return a supported interface orientation!'
supportedInterfaceOrientations is only called, if shouldAutorotate is set to YES
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.
from the documentation:
Note that the correct orientation is "Mask"! Did you try this?
Those are the wrong enums for
supportedInterfaceOrientations
. You need to useUIInterfaceOrientationMaskLandscapeLeft
, etc (note the word mask in the middle)Your code should look like this:
Also, make sure in your
Info.plist
you have set the correct orientations for you app because what you return fromsupportedInterfaceOrientations
is intersected with theInfo.plist
and if it can't find a common one then you'll get that error.