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

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

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

 

转载于:https://www.cnblogs.com/zhaozhongpeng/p/4867947.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值