当我将 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/