第四弹:iPhone/iPad的屏幕翻转

过完年回来了,发现过年基本上就是聚会-喝酒-喝多-睡觉-聚会.....

小学到高中,一轮一轮。亲朋好友,一波一波!真心胃疼啊!还好大学是在外地上的,不然还得加上大学同学就悲剧了。

 

今天回来说一说屏幕翻转

当设备屏幕翻转的时候,需要按照顺序分别调用下面四个函数

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation  //首先被调用,返回yes表示设备支持屏幕翻转,然后会调用下面3个函数;如果返回no就停止
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration  //在屏幕翻转之前调用,一般用来保存当前的状态,暂停正在运行着的活动,为将要进行的翻转做准备
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration  //在屏幕翻转的时候调用,一般用来设置翻转之后的如屏幕大小,长宽比例等设置
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation  //最后调用一般是用来匹配第二个函数,用来恢复之前的活动

另外,下面两个函数可以用来代替上面的第3个函数,基本上是一样的效果
willAnimateFirstHalfOfRotationToInterfaceOrientation:duration
willAnimateSecondHalfOfRotationFromInterfaceOrientation:duration
posted @ 2013-02-28 09:56  念苍生  阅读(568)  评论(0编辑  收藏  举报