gpt4 book ai didi

ios - 无法在 iPad iOS5 中为通用应用程序保留横向(iOS6 可以)

转载 作者:行者123 更新时间:2023-11-29 04:13:06 24 4
gpt4 key购买 nike

我正在使用 xcode4.5.1 中的主从模板来创建通用应用程序。为了在 iPad 中保持横向,我进行了以下设置。它在 iOS6 中工作,但在 iOS5 中始终保持纵向。我该如何解决这个问题? (项目链接:https://www.dropbox.com/s/7wm9l8kxhan6kp1/itstest.zip)

  1. plist

    <key>UISupportedInterfaceOrientations~ipad</key>

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

    </array>

    <key>UISupportedInterfaceOrientations~iphone</key>

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

    </array>
  2. 甚至在 Appdelegate.m 中添加以下内容

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

谢谢!

最佳答案

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

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

关于ios - 无法在 iPad iOS5 中为通用应用程序保留横向(iOS6 可以),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14096490/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com