如何在视图控制器层次结构中正确设置 interfaceOrientation 属性?
我有一个自定义视图控制器层次结构。 子视图控制器被简单地作为子视图添加到自定义父视图控制器中。父视图控制器还会在正确的时间调用子视图控制器的 -[willRotateToInterfaceOrientation:duration:]
和 -[didRotateFromInterfaceOrientation:]
方法。
一切似乎都按预期工作,但由于某种原因,interfaceOrientation
属性设置不正确,它始终是 UIInterfaceOrientationPortrait
。
当我旋转到横向时,如何让子视图控制器在 interfaceOrientation
中具有正确的值?
I have a custom view controller hierarchy.
A sub view controller is added, to a custom parent view controller simply as a subview. The parent view controller also calls the sub view controller's -[willRotateToInterfaceOrientation:duration:]
and -[didRotateFromInterfaceOrientation:]
methods at the correct time.
Everything seems to work as it should, but for some reason, the interfaceOrientation
property is not set correctly, it is always UIInterfaceOrientationPortrait
.
How do I get the sub view controller to have the correct value in interfaceOrientation
when I rotate to landscape?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不认为你可以,无论如何不使用公共 API。此外,您尝试这样做的事实表明您没有遵循 iOS 应用程序的推荐设计。考虑查看控制器编程指南
UIViewController 旨在管理整个屏幕的内容。一旦你违反了这个假设,你就会与框架作斗争,试图让你的观点按照你的预期行事。
I don't think you can, not using public APIs anyway. In addition the fact that you are trying to do so suggests that you are not following the recommended design for iOS apps. Consider the advice of the View Controller Programming Guide
UIViewControllers are intended to manage an entire screen worth of content. Once you violate that assumption you're going to be fighting the framework trying to get your views to behave as you expect.