屏幕旋转
2020-06-30 22:37
1041 查看
第一步
在
AppDelegate.h里增加一个属性
@property (nonatomic, assign) NSInteger allowRotation;
用来区分哪个界面可以横屏
哪个界面不可以
第二步
在
AppDelegate.m里增加一个方法
-(UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { if(self.allowRotation==1) { return UIInterfaceOrientationMaskAll; } else { return UIInterfaceOrientationMaskPortrait; } }
第三步
在需要横屏的界面调用以下代码即可
AppDelegate * appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate; appDelegate.allowRotation = 1; [[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIInterfaceOrientationPortrait] forKey:@"orientation"]; [[UIDevice currentDevice] setValue:[NSNumber numberWithInteger: UIDeviceOrientationLandscapeRight] forKey:@"orientation"]; [[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIDeviceOrientationPortraitUpsideDown] forKey:@"orientation"]; [[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIDeviceOrientationLandscapeLeft] forKey:@"orientation"];
Demo地址:https://github.com/YouZhiZheShiJingCheng/revolve/tree/master
相关文章推荐
- 简单入门 1.1
- 神经网络初步
- Java基础-快速入门
- ‘RefVariable‘ object has no attribute ‘_id‘
- solr管理界面详解
- 辅修经济学原理笔记
- 廖雪峰教程Git笔记
- Python读取文件基本方法
- 微软Python入门笔记
- 廖雪峰教程SQL笔记
- 按空格分割字符串
- 党建答题小程序复盘回顾终结篇
- python 子类关系
- ue4可导入文件类型
- Markdown语法快速入门学习笔记
- jquery学习笔记 | 选择器 / 样式、属性、节点操作 / 事件机制
- MongoDB 报错:use geoNear command rather than $near query
- JavaScript---数组的方法
- unity摄像机跟随角色移动
- 关于以太坊2.0,你想知道的都在这里