preferredInterfaceOrientationForPresentation 必须返回受支持的界面方向 [英] preferredInterfaceOrientationForPresentation must return a supported interface orientation

查看:23
本文介绍了preferredInterfaceOrientationForPresentation 必须返回受支持的界面方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此错误没有意义,因为首选方向 UIInterfaceOrientationLandscapeRight 由支持的方向返回

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;
}

错误:

由于未捕获的异常而终止应用'UIApplicationInvalidInterfaceOrientation',原因:'preferredInterfaceOrientationForPresentation 必须返回一个受支持的界面方向!'

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;
}

此外,请确保在您的 Info.plist 中为您的应用程序设置了正确的方向,因为您从 supportedInterfaceOrientations 返回的内容与 Info 相交.plist ,如果它找不到一个共同的,那么你会得到那个错误.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆