转:ios7(自动旋屏)iOS6不支持shouldAutorotateToInterfaceOrientation

参考开源中国——双子座教程ios7

http://my.oschina.net/plumsoft/blog/47289

发现 b2c交易在ios6上webview随屏幕旋转了,但是b2c支持横屏的,原因是ios6的委托

iOS6下的

- (BOOL)shouldAutorotateToInterf aceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
            return UIInterfaceOrientationIs Landscape(toInterfaceOrientation);
}

这个不会再被调用,取而代之的是这俩个组合:
- (BOOL)shouldAutorotate
{
     return YES;
}
 
- (NSUInteger)supportedInterfaceOrient ations
{
       return UIInterfaceOrientationMa skLandscape ;
}

当然,为了保持对旧版本系统行为的兼容性,不要删掉不用的那个调用。另外还有一个这个preferred朝向也可以加上
- (UIInterfaceOrientation)preferredInterfaceOrient ationForPresentation
{
       return UIInterfaceOrientationLa ndscapeRight;

}


b2c交易只支持横屏,网银交易需要支持横竖屏,所以如果在info.plist设置支持的方向,则再同以客户端下两种应用有冲突。解决这个问题的方法就是再前面的基础上再应用的delegate中加入如下回调:
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    if (clientstate == 0) 
        return UIInterfaceOrientationMaskAll;
    else
        return UIInterfaceOrientationMaskLandscape;
}

简单说明:

UIInterfaceOrientationMaskLandscape  支持左右横屏
UIInterfaceOrientationMaskAll  支持四个方向旋转
UIInterfaceOrientationMaskAllButUpsideDown 支持除了UpsideDown以外的旋转

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值