gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 17:02:58 24 4
gpt4 key购买 nike

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

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com