preferredInterfaceOrientationForPresentation必须返回支持的接口方向 [英] preferredInterfaceOrientationForPresentation must return a supported interface orientation

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

问题描述

此错误没有意义,因为首选方向 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屋!

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