iphone - 如何从嵌套的 UIViewController 中获取正确的 UIInterfaceOrientation

标签 iphone cocoa-touch ios

当我将 View Controller 的 View 放在顶级 View Controller 中时,UIInterfaceOrientation我从嵌套 View Controller 得到的不正确。如果我从顶层 View Controller 获得方向,我会得到正确的方向。 interfaceOrientation属性是只读的,所以我不能简单地设置它。如何让我的嵌套 View Controller 识别正确的方向?

Apple 可能不建议使用嵌套 View Controller ,但我将它们用于可重用性(通用应用程序)。

最佳答案

我也遇到过这个问题,我发现的唯一解决方法是在调用 parent 时调用 subview 的 willRotateToOrientation: 方法,或者如果你想检查何时加载,执行类似 [[ view2.superview viewController] imageOrientation]

基本上你必须自己处理它,这很痛苦。

关于iphone - 如何从嵌套的 UIViewController 中获取正确的 UIInterfaceOrientation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3262594/

相关文章:

iphone - 访问 JSON 文件以填充 UIPickerView

iphone - SystemSoundID有时随设备音量而变化

ios - 检测空 UITextField 中的退格键

iphone - 手势弹出导航 Controller

iPhone SDK : How to add an image to a UIBarButton?

ios - 设置选项 View 属性的属性时出现 EXC_BAD_ACCESS

objective-c - 如何检查 NSMutableArray 中是否存在对象

ios - 如何使用索引(:) with [SomeProtocol]?

ios - 在 viewDidAppear 之前以编程方式定位 UIView

objective-c - 在 iOS 中创建聊天功能 - 通过持续请求