supportInterfaceOrientations更改时如何通知系统?

Abh*_*ert 14 rotation uiviewcontroller uikit ios

我的根视图控制器的实现supportedInterfaceOrientations几乎总是返回UIInterfaceOrientationMaskAll,但是有一个返回的边缘情况UIInterfaceOrientationMaskLandscape.

如果用户旋转设备,这是有效的.但是,如果设备处于纵向模式supportedInterfaceOrientations,则除非用户手动旋转设备,否则不会调用该方法.

如何以编程方式告诉系统此方法的返回值已更改?

根据文档,似乎我应该能够调用,[UIViewController attemptRotationToDeviceOrientation]但这没有任何影响(supportedInterfaceOrientations从未调用,屏幕不旋转).

我找到了其他人发布的各种解决方法来尝试解决这个问题,但是我的测试中没有一个可以工作.我怀疑他们可能在iOS 5.0中工作,但不是iOS 6.0.

YES在根视图控制器的shouldAutorotate方法中返回.

dan*_*elM 0

引用 Apple 的 UIViewController 类参考:

注意:在启动时,应用程序应始终将其界面设置为纵向。在 application:didFinishLaunchingWithOptions: 方法返回后,应用程序使用上述视图控制器旋转机制在显示窗口之前将视图旋转到适当的方向。

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/Reference/Reference.html

如果界面以纵向启动,即使用户在设备侧面打开应用程序,自动旋转也应该能够处理调整。

更新:我发现这篇文章应该有助于启动后的轮换。显然,iOS 6 会通过导航控制器来确定支持的设备方向。

如何在 iOS 6 中强制 UIViewController 为纵向