首页 > 移动平台 > 详细

关于IOS屏幕旋转的几个问题1.常规设置2.个别页面强制固定横竖屏

时间:2015-06-17 12:52:55      阅读:1338      评论:0      收藏:0      [点我收藏+]

1.常规设置屏幕旋转  (Device Orientation || info.plist-----这两个地方的设置是同步的)

 

1)targets->General->Deployment Info->Device Orientation  直接勾选想要的设备定位全局属性

 

技术分享

 

 

2)Supporting Files->Info.plist->Supported interface orientations 增删属性值

技术分享

 

 

 

2.个别页面强制横竖屏

新建一个NavigationController类

实现下面三个方法

 

-(BOOL)shouldAutorotate

{//是否支持自动旋转

    return YES;

}

-(NSUInteger)supportedInterfaceOrientations

{//支持的旋转方向

    return [self.viewControllers.lastObject

            supportedInterfaceOrientations];

}

-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation

{//进入界面后的默认方向

    return [self.viewControllers.lastObject

            preferredInterfaceOrientationForPresentation];

}

 

 

技术分享

 

 

如果push出的ViewController需要改变屏幕方向横屏或者竖屏

在当前的ViewController中重写这三个方法,但是如果NavigationController中实现了shouldAutorotate这个方法,则在ViewController中不再执行重写的shouldAutorotate方法。

 

-(BOOL)shouldAutorotate

{//是否支持自动旋转

    return YES;

}

 

-(NSUInteger)supportedInterfaceOrientations

{//支持的旋转方向

    return  (枚举值);

}

-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation

{//进入界面后的默认方向

    return  (枚举值);

}

 

关于IOS屏幕旋转的几个问题1.常规设置2.个别页面强制固定横竖屏

原文:http://www.cnblogs.com/hanyutong/p/4582745.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!