preferredInterfaceOrientationForPresentation必须返回支持的接口方向 [英] preferredInterfaceOrientationForPresentation must return a supported interface orientation
问题描述
此错误没有意义,因为首选方向 UIInterfaceOrientationLandscapeRight
由支持的方向返回
// iOS6
- (BOOL)shouldAutorotate
{
return NO;
}
- (NSUInteger)supportedInterfaceOrientations
{
return(UIInterfaceOrientationLandscapeRight | UIInterfaceOrientationLandscapeLeft);
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeRight;
}
错误:
< >
由于未捕获的异常而终止应用程序
'UIApplicationInvalidInterfaceOrientation',原因:
'preferredInterfaceOrientationForPresentation必须返回支持的
接口方向!'
- (BOOL)shouldAutorotate
{
return NO;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeRight;
}
此外,请确保您的 Info.plist
您为应用设置了正确的方向,因为您从 supportedInterfaceOrientations
返回的内容与 Info.plist
,如果它找不到一个通用的,那么你会得到这个错误。
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!'
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.
这篇关于preferredInterfaceOrientationForPresentation必须返回支持的接口方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!