关于强制横竖屏的几点说明

在应用中,我们有时需要将单独的一个页面强制横屏,而其他页面还是保持竖屏显示。在强制横屏时,我走了一点弯路,希望可以帮助到和我一样的小白O(∩_∩)O哈哈~

ios6+的系统下在强制横屏时,需要在controller中实现下面三个方法。

-(BOOL)shouldAutorotate //是否自动旋转
{
    return NO;
}

-(NSUInteger)supportedInterfaceOrientations//controller支持的方向
{
    return UIInterfaceOrientationMaskLandscape;
}
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation//默认的方向
{
    return UIInterfaceOrientationLandscapeRight;
}

但是有时候我们会发现系统不会调用方法。后来看到一位大神的文章,恍然大悟。原来,如果你的controller添加了navgationcontroller,那么系统会去调用navgationcontroller里面的这些方法而忽略controller里的这些方法。值得注意!!!

有时我们会遇到这个错误,preferredInterfaceOrientationForPresentation must return a supported interface orientation!'也是由于这个原因和supportinterface共同造成的。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值