关于UIInterfaceOritation 和 UIDeviceOritation
来源:互联网 发布:php文件管理系统 编辑:程序博客网 时间:2024/06/04 00:24
原文链接:http://blog.163.com/hongbin89@126/blog/static/112853955201331432531787/
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
};
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];
- 关于UIInterfaceOritation 和 UIDeviceOritation
- 关于 ## 和#
- 关于<和>
- 关于||和&&
- 关于#和##
- 关于framework和runtime
- 关于PASCAL 和 FAR
- 关于ftpd和tcpd
- 关于mutilbox 和 checkbox
- 关于BORLAND和微软
- 关于进程和线程
- 关于wiki和Rss
- 关于我和这里
- 关于Zope和Plone
- 关于证书和签名
- 关于volatile和synchronized
- 关于sort 和 qsort
- 关于进程和会话
- js移动div改进(兼容)
- 高通平台msm8909 LK 实现LCD 兼容
- export http://blog.csdn.net/hikaliv/article/details/4474835
- 解决centos不能上网
- Dinic 算法求最大流(最小割) POJ 2536
- 关于UIInterfaceOritation 和 UIDeviceOritation
- Leetcode -- Best Time to Buy and Sell Stock IV
- appium for windows 环境搭建
- 数据结构之并查集
- javascript 时间处理问题
- C++primer学习:面象对象程序设计(5):容器与继承
- javax.servlet.jsp.JspException: No collection found
- Android 动画之ScaleAnimation应用详解
- 第九周--项目2对称矩阵压缩存储的实现与应用(2)