码迷,mamicode.com
首页 > 其他好文 > 详细

设置屏幕旋转 (以下方法按着顺序设置)

时间:2015-10-10 18:34:53      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:

UIInterfaceOrientationUnknown            = UIDeviceOrientationUnknown, 界面取向未知

    UIInterfaceOrientationPortrait           = UIDeviceOrientationPortrait, 正常的肖像模式 就是向上

    UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown, 向下

    UIInterfaceOrientationLandscapeLeft      = UIDeviceOrientationLandscapeRight,  向右

UIInterfaceOrientationLandscapeRight     = UIDeviceOrientationLandscapeLeft   向左

 

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

{

 返回YES支持旋转 NO不支持旋转

通过获取UIDevice的userInterfaceIdiom属性,可以检测到当前程序是运行在iphone或者是ipad上

  if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {

      return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);

  } else {

      return YES;

  }

}

 

这个方法是发生在翻转开始之前。一般用来禁用某些控件或者停止某些正在进行的活动,比如停止视频播放

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration

 

-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration

这个方法发生在翻转的过程中,一般用来定制翻转后各个控件的位置、大小等。可以用另外两个方法来代替:willAnimateFirstHalfOfRotationToInterfaceOrientation:duration:   和  willAnimateSecondHalfOfRotationFromInterfaceOrientation:duration:

  

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation

这个方法发生在整个翻转完成之后。一般用来重新启用某些控件或者继续翻转之前被暂停的活动,比如继续视频播放。

 

设置屏幕旋转 (以下方法按着顺序设置)

标签:

原文地址:http://www.cnblogs.com/zhaozhongpeng/p/4867947.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!