关于UIInterfaceOritation 和 UIDeviceOritation
2015-10-29 18:56
411 查看
原文链接:http://blog.163.com/hongbin89@126/blog/static/112853955201331432531787/
1、UIDeviceOrientation是设备的方向,只能读取不能设置,支持6个方向,
UIInterfaceOrientation是软件的方向,可以读取可以设置。
注意:UIInterfaceOrientation的横屏的左边和右边跟UIDeviceOrientation刚好相反。
2、如果需要获取设备方向变化(UIDeviceOrientation)的消息的话,需要注册UIDeviceOrientationDidChangeNotification通知。
在注册通知时,需要先调用UIDevice的beginGeneratingDeviceOrientationNotifications方法
同时,在结束时,需要移除改通知消息
1、UIDeviceOrientation是设备的方向,只能读取不能设置,支持6个方向,
typedef NS_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};
UIInterfaceOrientation是软件的方向,可以读取可以设置。
typedef NS_ENUM(NSInteger, UIInterfaceOrientation) { UIInterfaceOrientationPortrait = UIDeviceOrientationPortrait, UIInterfaceOrientationPortraitUpsideDown= UIDeviceOrientationPortraitUpsideDown, UIInterfaceOrientationLandscapeLeft = UIDeviceOrientationLandscapeRight, UIInterfaceOrientationLandscapeRight = UIDeviceOrientationLandscapeLeft};
注意:UIInterfaceOrientation的横屏的左边和右边跟UIDeviceOrientation刚好相反。
2、如果需要获取设备方向变化(UIDeviceOrientation)的消息的话,需要注册UIDeviceOrientationDidChangeNotification通知。
在注册通知时,需要先调用UIDevice的beginGeneratingDeviceOrientationNotifications方法
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];[notificationCenter addObserver:self selector:@selector(deviceOrientationDidChange) name:UIDeviceOrientationDidChangeNotification object:nil];
同时,在结束时,需要移除改通知消息
[notificationCenter removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil];[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
相关文章推荐
- 关于mysql的错误 - no query specified
- Android - Get Bluetooth UUID for this device
- iOS UI设计: 在Autolayout的布局上用constraint实现动画
- iOS流布局UICollectionView系列七——三维中的球型布局
- Requests高级用法
- Java - String vs StringBuffer vs StringBuilder
- 【解决方法】You must rebuild it with bitcode enabled (Xc
- Golang的循环中break和continue语句的用法讲解
- 杭电1242Rescue(深搜)
- uestc 1221 Ancient Go
- UIViewController的生命周期
- iOS开发-CALayer/Core Animation/UIView动画封装
- UIButton: set image for selected-highlighted state
- 在iOS 8中使用UIAlertController
- 获取视图的绝对坐标(相对于UIWindow)
- 8.8.4 Estimating Query Performance 评估查询性能
- leetcode Repeated DNA Sequences && 代替两次判断
- js bool true false 比较
- Ant之build.xml详解
- UIScrollView 实践经验