IOS 4,5和6上对设备方向支持方法的变更

IOS4,5上,设备的支持方向是每个view controller定义,默认是只能portrait,修改的话调用shouldAutorotateToInterfaceOrientation:方法,如:

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
    return toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight;

}

IOS 6以后,设备的支持方向,只能在rootviewcontroller(或Presentmodelviewcontroller)设定支持方向,subview或者 child Viewcontroller根据rootviewcontroller来,

rootviewcontroller里面调用:

// New Autorotation support.
- (BOOL)shouldAutorotate NS_AVAILABLE_IOS(6_0);
- (NSUInteger)supportedInterfaceOrientations NS_AVAILABLE_IOS(6_0);
//(当shouldAutorotate返回YES时,调用第二个方法,设定支持方向)


如果是presentviewcontroller 会额外调用

preferredInterfaceOrientationForPresentation 


注:如果要兼容4、5,则要实现shouldAutorotateToInterfaceOrientation方法,如上面所示代码。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值