[英]iOS: Rotating an iPad, what stage to change view?
我的应用程序针对每个方向的UI结构都非常不同。
我应该在iPad的旋转生命周期的哪个阶段删除,然后添加方向的UI以确保最平稳的过渡?
处理自动旋转时,您需要注意以下4种主要方法:
shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
duration:(NSTimeInterval)duration
didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
现在,我处理旋转的方式为:
调整willAnimateRotationToInterfaceOrientation
所有帧;
在willRotateToInterfaceOrientation
添加/删除子视图(如果需要);
在didRotateFromInterfaceOrientation
中还didRotateFromInterfaceOrientation
视图(如果需要)。
一般来说,我将修改willAnimateRotationToInterfaceOrientation
中可设置动画的所有属性; 虽然我会执行willRotateToInterfaceOrientation
/ didRotateFromInterfaceOrientation
所有无法修改的修改。
这就是UIViewController参考关于willRotate
/ didRotate
:
要临时关闭不需要的功能,否则可能会在方向更改过程中导致其他问题的功能,您可以覆盖willRotateToInterfaceOrientation:duration:方法并在其中执行所需的操作。 然后,您可以覆盖didRotateFromInterfaceOrientation:方法,并在方向更改完成后使用它重新启用这些功能。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.