iOS中屏幕旋转流程是这样的:
1、设备旋转的时候,UIKit接收到旋转事件。
2、UIKit通过AppDelegate通知当前程序的window。
3、Window会知会它的根视图,判断该view controller所支持的旋转方向,完成旋转。
4、如果存在弹出的view controller的话,系统则会根据弹出的view controller,来判断是否要进行旋转。
值得一提的是push和present进行视图切换的时候,push跑到根视图进行判断能否旋转,present直接在当前视图判断能否旋转。判断能否旋转的方法为:
- (BOOL)shouldAutorotate
{
return YES;
}以下这些方法是在当前页面在屏幕旋转时判断为允许旋转后调用的,可以做一些操作(8_0以后不能用。。。)。
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration NS_DEPRECATED_IOS(2_0,8_0, "Implement viewWillTransitionToSize:withTransitionCoordinator: instead");
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation NS_DEPRECATED_IOS(2_0,8_0);
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration NS_DEPRECATED_IOS(3_0,8_0, "Implement viewWillTransitionToSize:withTransitionCoordinator: instead");

1万+

被折叠的 条评论
为什么被折叠?



