我在xcode4.5.1中使用主从模板创建通用应用。
为了使iPad保持风景,我进行了以下设置。它可以在iOS6中使用,但始终可以在iOS5中保持人像。我该如何解决这个问题? (项目链接:https://www.dropbox.com/s/7wm9l8kxhan6kp1/itstest.zip


列表

<key>UISupportedInterfaceOrientations~ipad</key>

<array>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>

</array>

<key>UISupportedInterfaceOrientations~iphone</key>

<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>

</array>

甚至在Appdelegate.m中添加以下内容

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}



谢谢!

最佳答案

方法shouldAutorotateToInterfaceOrientation不会在AppDelegate中被调用,仅在视图控制器(docs)中被调用。将以下代码放入您的视图控制器中(尽管对于您的特定项目,我认为仅将其放在您的MasterViewController中就足够了):

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
        return UIInterfaceOrientationIsPortrait(interfaceOrientation);
    else
        return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}

10-07 19:13
查看更多