iphone - 手动路由 willRotateToInterfaceOrientation 调用

标签 iphone objective-c ios cocoa

我有多个 UIViewController,它们的 View 通过添加 subview 相互嵌套。我只是让我所有的观点都自动改变了方向,除了一个。堆栈末尾的那个。我还意识到 willRotateToInterfaceOrientation 方法不会传播到 subview Controller 。处理这个问题的最佳方法是什么?我应该尝试手动将调用路由到 subview 吗?

不旋转的最终 Controller 取自示例照片查看器应用程序 PhotoViewController,它依赖于调用的 willRotateToInterfaceOrientation 方法。

如有任何帮助,我们将不胜感激。

最佳答案

对于 iOS 4.3 和更早版本,路由对 willRotateToInterfaceOrientation(和其他此类方法)的调用是完全好的做法。问题是没有 View Controller 是其他 View Controller 的 subview Controller 的概念。

在 iOS 5 中,引入了容器 View Controller 的概念(事实证明 UINavigationController 和 UITabBarController 一直都是特殊的“容器 View Controller ”——请注意,这些 View Controller 已经将这些方法路由到您自己的 View Controller ! ).容器 View Controller 的概念形式化了这种路由方法的想法,例如从父 View Controller 到 subview Controller 的 willRotateToInterfaceOrientation

您应该查看“UIViewController”类引用文档的“实现容器 View Controller ”部分。 iOS5 目前处于开发者预览阶段,因此您需要成为注册的 iOS 开发者才能访问它。从 iOS5 开始,这将是解决您所描述问题的首选方法。

关于iphone - 手动路由 willRotateToInterfaceOrientation 调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7180605/

相关文章:

ios - 通过其任何 UI 元素(例如按钮、标签、文本字段)仅获取父类的名称

ios - NSURLSession 辅助类

ios - Swift `yyyy-MM-dd' T'HH :mm:ss. sssZ` 字符串至今

iphone - 我无法捕获 FMDB 空结果集

ios - 在调度 block 中分配的变量返回 null

c++ - 如何从 ImageMagick 图像获取 c 缓冲区

ios - 如何使用oauth发送https GET请求

ios - UIWebView:当应用程序进入后台时,HTML5 音频在 iOS 6 中暂停

iphone - -[CFString长度] : message sent to deallocated instance 0x3881940 when i scroll to near the bottom of a table on iphone

ios - 我的功能有什么问题