【问题标题】:Force iPad app to launch in portrait when landscape is supported支持横向时强制 iPad 应用以纵向启动
【发布时间】:2012-10-05 16:41:27
【问题描述】:

我的 iPad 应用在应用的某处包含一个支持横向模式的视图。

对于要调用的视图中的 shouldAutorotateToInterfaceOrientation,我必须在 info.plist 中声明支持横向。

问题:

应用程序启动时显示的 UITabController 不支持横向模式,我确保在所有选项卡栏的视图控制器中指定它。 然而,当设备处于横向模式时启动应用程序时,tabcontroller 以横向显示并且所有选项卡看起来都变形了。

info.plist 设置为仅支持纵向模式会强制应用正确启动,但随后会在可旋转视图控制器上忽略 shouldAutorotateToInterfaceOrientation

我在启动时尝试的另一个选项是:

[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];

这实际上迫使应用以纵向显示,但也使应用忽略了可旋转视图控制器上的进一步设备旋转。

更新: 这只是 iOS6 的问题,无法在模拟器上发现

【问题讨论】:

    标签: ios ipad ios6 device-orientation landscape-portrait


    【解决方案1】:

    查看iOS 6 rotations: supportedInterfaceOrientations doesn´t work?

    你需要继承你的 TabBarController 并覆盖它的 shouldAutoRotateToInterfaceOrientation 来控制这个 ViewController 如何定位自己。

    【讨论】:

    • 现场!这只是一个 iOS6 问题(DOH)。我已经对我的标签进行了子类化,但 shouldAutoRotateToInterfaceOrientation 没有影响。在 iOS6 中,shouldAutorotate 应该返回 YES 并且 supportedInterfaceOrientations应该返回肖像。此外,70% 的故事,为了让状态栏与支持的方向对齐,确保您使用 [window setRootViewController:tabBarController],如果您正在处理一些遗留代码,例如 suggested here
    • @CSmith,兄弟你能看看我的问题stackoverflow.com/questions/46127376/…吗?
    猜你喜欢
    • 2015-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-29
    • 2015-01-01
    • 1970-01-01
    • 2012-02-14
    相关资源
    最近更新 更多