设置横竖频 设备方向 软件方向
来源:互联网 发布:淘宝上怎么买域名 编辑:程序博客网 时间:2024/05/16 03:08
[UIDevice currentDevice].orientation ==UIDeviceOrientationPortrait
获取设备的方向方法1、UIDeviceOrientation是设备的方向,只能读取不能设置,
typedefNS_ENUM(NSInteger,UIDeviceOrientation){
UIDeviceOrientationUnknown,
UIDeviceOrientationPortrait, // Device oriented vertically, home button on the bottom
UIDeviceOrientationPortraitUpsideDown, // Device oriented vertically, home button on the top
UIDeviceOrientationLandscapeLeft, // Device oriented horizontally, home button on the right
UIDeviceOrientationLandscapeRight, // Device oriented horizontally, home button on the left
UIDeviceOrientationFaceUp, // Device oriented flat, face up
UIDeviceOrientationFaceDown // Device oriented flat, face down
};
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];
设置软件方向2UIInterfaceOrientation是软件的方向,可以读取可以设置。
typedefNS_ENUM(NSInteger,UIInterfaceOrientation){
UIInterfaceOrientationPortrait =UIDeviceOrientationPortrait,
UIInterfaceOrientationPortraitUpsideDown=UIDeviceOrientationPortraitUpsideDown,
UIInterfaceOrientationLandscapeLeft =UIDeviceOrientationLandscapeRight,
UIInterfaceOrientationLandscapeRight =UIDeviceOrientationLandscapeLeft
};
注意:UIInterfaceOrientation的横屏的左边和右边跟UIDeviceOrientation刚好相反。
2、如果需要获取设备方向变化(UIDeviceOrientation)的消息的话,需要注册UIDeviceOrientationDidChangeNotification通知。
在注册通知时,需要先调用UIDevice的beginGeneratingDeviceOrientationNotifications方法
[[UIDevicecurrentDevice]beginGeneratingDeviceOrientationNotifications];[notificationCenteraddObserver:selfselector:@selector(deviceOrientationDidChange)name:UIDeviceOrientationDidChangeNotificationobject:nil];
同时,在结束时,需要移除改通知消息
[notificationCenter removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil];
[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
- 设置横竖频 设备方向 软件方向
- 8.29 设置设备支持方向
- cocos2d 2.x 设备方向设置问题
- Swift3.0 -- 设置设备方向支持
- swift3 设置设备方向支持(supportedInterfaceOrientations)
- 设备方向,视图控制器方向和视图方向,监测与设置,以及相互之间的关系
- 方向~
- 方向
- 方向
- 方向
- 方向..
- 方向
- 方向
- 方向
- 方向
- 方向
- 方向
- 方向
- android相对布局
- python 有关时间操作的一些代码
- PHP学习路程感悟 -- 对路了真好
- RingProgressBar
- PHP 解析HTML元素实例 -- vb2005xu PHP进阶教程之一
- 设置横竖频 设备方向 软件方向
- Java ResultSetMetaData之getColumnName与getColumnLabel
- PHP一行代码集成雅虎宝贝鱼在线翻译功能 -- JAVAEYE不支持IE8
- 我是色色 -- 个人站开通 (*^__^*) 嘻嘻……
- Android模拟器:Genymotion
- 重构 css 布局 -- 重构公司网站,面向web2.0规范前端项目开发
- JS创建对象多种方法
- 死亡与新生: 终结JAVA包袱,向往C#轻装上阵
- 求两个数高位相同的部分--算法由中国PHP联盟的vincent-武汉(282159887) 提供