1

我有一个适用于 ios6 的应用程序。如果应用程序在手机上运行,​​我只想支持纵向。如果在平板电脑上,我想支持所有方向。我认为这会做到(在我的视图控制器中):

- (NSUInteger)supportedInterfaceOrientations
{
    if ([Util isPhoneFormFactor]) {
        return UIInterfaceOrientationPortrait;
    }

    return UIInterfaceOrientationMaskAll;
}

但这会在我的 iphone 模拟器上启动时引发异常:

*** Terminating app due to uncaught exception 
'UIApplicationInvalidInterfaceOrientation', reason: 
'Supported orientations has no common orientation with 
 the application, and shouldAutorotate is returning YES'

我将此解释为意味着我必须覆盖以下内容并返回 NO:

- (BOOL) shouldAutorotate
{
    return NO; 
}

这修复了异常,但是在 ipad 模拟器上旋转时,我不再旋转了。这样做的正确方法是什么?

谢谢

4

1 回答 1

3

你说UIInterfaceOrientationPortrait但你的意思是UIInterfaceOrientationMaskPortrait。你漏掉了Mask

于 2013-01-04T06:36:26.450 回答