首页 > 其他 > 详细

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

时间:2015-10-10 18:33:13      阅读:195      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!