iOS屏幕旋转

来源:互联网 发布:js隐藏span 编辑:程序博客网 时间:2024/06/05 04:52

    

  项目需求是在导航栏基类下保持竖屏,步骤如下:

  第一步如下图,表示设备只支持竖屏

    


  第二步,通过继承导航类创建一个类,在该类里面实现以下方法:

 

- (BOOL)shouldAutorotate {    return [self.visibleViewController shouldAutorotate];}- (UIInterfaceOrientationMask)supportedInterfaceOrientations{    return [self.visibleViewController supportedInterfaceOrientations];}

  然后在导航子视图里面贴上代码

<pre name="code" class="objc">- (BOOL)shouldAutorotate{    return NO;}- (UIInterfaceOrientationMask)supportedInterfaceOrientations {    return UIInterfaceOrientationMaskPortrait;}- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {    return UIInterfaceOrientationPortrait;}


  具体的不再赘述,感兴趣的可以看看这篇文章,讲得比较详细:http://www.jianshu.com/p/73be6d0e152f

 
0 0
原创粉丝点击