iphone - iPad 方向更改问题

标签 iphone ipad uiinterfaceorientation

我的 iPhone 应用程序在 iPad 上运行时在支持方向更改方面显示一些奇怪的行为。

应用程序启动时有一个 View Controller (为了便于论证,将其称为 View A)和导航 Controller ,并且 shouldAutorotateToInterfaceOrientation 仅针对纵向返回 YES。在导航 Controller 上,我推送了一个 View Controller ( View B),它也仅针对纵向返回 YES。然后,我将另一个 View Controller ( View C)推到支持所有旋转的导航 Controller 上,并根据旋转方向调整屏幕上的项目。

当它在 iPhone 模拟器和设备上运行时,如果您在 View C 上旋转到横向,然后点击后退按钮返回到 View B,它会执行正确的操作并将 View B 切换回纵向模式。 (在模拟器中,它甚至会自动将模拟器旋转回纵向。)

我遇到的问题是,当我在 iPad 模拟器和设备上执行完全相同的事件序列时,出现的 View B 不会旋转回纵向,并且导航 Controller 仍然显示 View C 的信息然后,我点击后退按钮, View 保持不变,但导航 Controller 显示 View B 正常(但仍然处于横向模式)。然后,如果我再次点击后退按钮, View A 会出现在 View B 导航栏项目下方,最后再次点击后退会将我置于带有导航栏 A 项目的 View A 上。

如果我在 iPad 上查看 B 并开始旋转,shouldAutorotateToInterfaceOrientation 将触发 NO,直到我进入纵向模式,然后一切恢复正常。

该应用程序是使用最新发布的 iPhone SDK 版本构建的,build设置如下:iPhone Simulator 4.0 的基础 SDK、iPhone 的目标设备系列、iPhone OS 3.1.3 的 iPhone OS 部署目标。

有什么想法吗?

最佳答案

苹果声明:

Case: All child view controllers in your UITabBarController or UINavigationController do not agree on a common orientation set.

Response: To make sure that all your child view controllers rotate correctly, you must implement shouldAutorotateToInterfaceOrientation for each view controller representing each tab or navigation level. Each must agree on the same orientation for that rotate to occur. That is, they all should return YES for the same orientation positions.

http://developer.apple.com/iphone/library/qa/qa2010/qa1688.html

您可以在导航 Controller 中而不是在各个 View 中设置设备方向。然后您可以检查堆栈上的 View 并根据结果进行旋转。通过这种方式,导航 Controller 也可以处理所有方向。

关于iphone - iPad 方向更改问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3213885/

相关文章:

ios - UIImagePickerController 在缩放时显示黑条 – 这是 iOS 中的错误吗?

iphone - 查看旋转通知 : why didRotateFromInterfaceOrientation: doesn't get called?

iphone - 有没有办法模拟多个 iOS 设备运行 Bonjour 网络应用程序?

iphone - iOS 应用程序与 pinterest 的集成

iphone - 无法在 UITableView 中显示文本

javascript - 如何从进入休眠状态的 WebSocket 客户端计算机或进入后台的应用程序恢复(iPad 上的 Safari)

iphone - IO6 不调用 -(BOOL)shouldAutorotate

iphone - 从 super View 中删除表 subview

iphone - 如何将 NSObject 从 NSDictionary 转换为 NSString?

ios - 多个核心数据实例