此错误没有意义,因为UIInterfaceOrientationLandscapeRight支持的方向返回首选方向
//iOS6
-(BOOL)shouldAutorotate
{
    return NO;
}
-(NSUInteger)supportedInterfaceOrientations
{
    return (UIInterfaceOrientationLandscapeRight | UIInterfaceOrientationLandscapeLeft);
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationLandscapeRight;
}
错误:
由于未捕获的异常'UIApplicationInvalidInterfaceOrientation'而终止应用程序,原因是:'preferredInterfaceOrientationForPresentation必须返回支持的接口方向!'
lms*_*lms 57
您的代码应如下所示:
-(BOOL)shouldAutorotate
{
    return NO;
}
-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationLandscapeRight;
}
此外,请确保Info.plist您已为自己的app设置了正确的方向,因为您返回的supportedInterfaceOrientations内容与之相交,Info.plist如果找不到常见的方向,那么您将收到该错误.
coc*_*oco 13
如果shouldAutorotate设置为YES,则仅调用supportedInterfaceOrientations
- (BOOL)shouldAutorotate
{
    return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationLandscapeRight;
}
对我来说最简单的方法是设置Info.plist

如果您想支持iOS 5,请在视图控制器中使用此代码.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
这些是错误的枚举supportedInterfaceOrientations.你需要使用UIInterfaceOrientationMaskLandscapeLeft等(注意中间的单词掩码)
| 归档时间: | 
 | 
| 查看次数: | 38394 次 | 
| 最近记录: |