【问题标题】:iOS6 Preferred Interface Orientation Not WorkingiOS6首选界面方向不起作用
【发布时间】:2013-05-28 17:06:01
【问题描述】:

我正在尝试处理 iOS6 自动旋转混乱。

我已经查看了几乎每一个与之相关的 SO 问题,无论我尝试什么,我都无法按照我的需要进行轮换。

应用使用storyboards,布局如下:

Navigation controller ---> Root view controller ---> Tab view controller ---> View controller ---> Landscape view controller.

当我旋转模拟器时,视图控制器会自动旋转,但是当返回到前一个视图(设置为纵向)时,视图变成了横向,而它应该是纵向的。如果我将模拟器旋转回来,视图会再次自动旋转为纵向,但这应该是自动完成的!

我已经实现了(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation,它不会在我放入的任何视图控制器中被调用。

我已将 NavigationController 子类化为返回 topViewControllershouldAutoRotatesupportedInterfaceOrientationspreferredInterfaceOrientationForPresentation,并且在旋转模拟器时自动旋转似乎可以工作,但 preferredInterfaceOrientationForPresentation 从来没有完成它的工作。

有没有人可以解决这个问题?

【问题讨论】:

  • 在界面生成器中,对于每个视图,都有一个部分可以设置在给定方向上的外观。你玩过吗?
  • 是的,Simulated Metrics 中的方向设置为适合每个视图的纵向和横向。
  • preferredInterfaceOrientationForPresentation 仅对模态视图控制器调用。
  • 为每个视图控制器实现 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation。
  • 你是否在 info.plist 文件中设置了方向??

标签: iphone ios ios6 autorotate


【解决方案1】:

Apple 似乎移除了将视图推送到特定方向的功能。 preferredInterfaceOrientationForPresentation 确实会被调用,但仅在弹回或呈现视图控制器时才会调用。我不得不展示我的横向视图而不是推送它,并设置shouldAutoRotate = NO。

详情请参阅:In iOS6, trouble forcing ViewController to certain interfaceOrientation when pushed on stack

【讨论】:

    猜你喜欢
    • 2012-12-17
    • 1970-01-01
    • 1970-01-01
    • 2012-09-08
    • 2015-12-23
    • 2016-08-14
    • 1970-01-01
    • 1970-01-01
    • 2014-05-12
    相关资源
    最近更新 更多