您的位置:首页 > 移动开发 > IOS开发

iOS 屏幕旋转 强制旋转

2016-07-05 15:36 543 查看
大部分情况是 有且仅有一个页面横屏或者不横屏。so....

情况一:使用 UINavigationController 的项目

比如仅有一个页面支持横屏:

1、plist文件

(设置2后,plist就会改变)



2、 设置所支持的方向



3、代码:

重写一个继承于UINavigationController的类,还有要横屏的Controller都要用下面的代码,但要相应修改YES 还有 NO

- (BOOL)shouldAutorotate{
return YES;
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations{
//支持方向
return UIInterfaceOrientationMaskLandscape;
}

-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
//当前viewcontroller默认的屏幕方向
return UIInterfaceOrientationLandscapeLeft;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
//return (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft);

}

http://www.cnblogs.com/niit-soft-518/p/5611298.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息