我有一个带有一堆 subview 的 UIViewController,如果 iPad 处于纵向或横向模式,我需要以不同的顺序进行布局。我希望能够获取 UIViewController 的 View 在旋转后将转换成的大小,以便我可以为我的 subview 计算新的帧集。但是,我还没有找到任何方法在旋转发生之前获得这个新尺寸,并且当旋转发生时已经太晚了,因为我无法将 subview 转换到它们的新位置的动画。
有人知道解决这个问题的方法吗?
最佳答案
您是否尝试过willAnimateRotationToInterfaceOrientation:duration:
。正如文档所述:
By the time this method is called, the interfaceOrientation property is already set to the new orientation. Thus, you can perform any additional layout required by your views in this method.
我相信 View Controller 的 View 也应该在这个方法中有它的新维度。
关于iphone - 旋转后获取 UIViewController View 的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4432463/