此错误是没有意义的,为择优取向UIInterfaceOrientationLandscapeRight
由支撑定向preferredInterfaceOrientationForPresentation必须返回一个支持的接口方向
//iOS6
-(BOOL)shouldAutorotate
{
return NO;
}
-(NSUInteger)supportedInterfaceOrientations
{
return (UIInterfaceOrientationLandscapeRight | UIInterfaceOrientationLandscapeLeft);
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeRight;
}
返回错误:
终止应用程序由于未捕获的异常 'UIApplicationInvalidInterfaceOrientation',原因: 'preferredInterfaceOrientationForPresentation必须返回受支持的 接口方向!'
我发现这让我很伤心!我有一个通用的应用程序共享viewcontroller代码,并使用上述代码测试用户惯用语。 iPad必须只是风景,而且所有酒吧的肖像都需要风景。我无法在 – user7865437
处获得正确的方向请注意,它是“UIInterfaceOrientationMaskLandscape”的“面具”部分,它是此答案的重要部分。原来的海报用户在他的方法中使用了错误的枚举。苹果为这种方法创建了一套新的enum/optionss似乎有点愚蠢,导致人们犯这个简单的错误 - 另外Xcode甚至不提供任何编译器时间检查,因为该方法返回NSUInteger。 –
@lms,我的整个应用程序只支持肖像模式,只有一个视图(需要支持横向)。在Plist中,我只为肖像设置了方向,并且在上面的代码中写入了我想要改变风景方向的位置。但它给UIInterfaceOrientationLandscapeRight或UIInterfaceOrientationLandscapeLeft.But我想在我看来。你能告诉我如何得到它。 –