IOS 学习笔记12 设备旋转

关于UIDeviceOrientation和UIInterfaceOrientation 
02  
03 1,UIDeviceOrientation   是设备的方向,只能读取不能设置,支持6个方向,
04 typedef的 NS_ENUM(NSInteger的, UIDeviceOrientation ) {
05     UIDeviceOrientationUnknown ,
06     UIDeviceOrientationPortrait ,               //设备垂直方向,在底部的home键
07     UIDeviceOrientationPortraitUpsideDown,    垂直方向,home键的顶部
08     UIDeviceOrientationLandscapeLeft,          //设备水平方向,home键在右边
09     UIDeviceOrientationLandscapeRight,            //设备水平方向,home键在左侧
10     UIDeviceOrientationFaceUp,                         //设备面向平板,正视
11  
12     UIDeviceOrientationFaceDown                     //面向平板设备,脸朝下
13  
14 };
15  
16  
17  
18 UIInterfaceOrientation是软件的方向,可以读取可以设置。
19 typedef的 NS_ENUM(NSInteger的, UIInterfaceOrientation ) {
20     UIInterfaceOrientationPortrait =  UIDeviceOrientationPortrait,
21     UIInterfaceOrientationPortraitUpsideDown =  UIDeviceOrientationPortraitUpsideDown,
22     UIInterfaceOrientationLandscapeLeft =  UIDeviceOrientationLandscapeRight
23     UIInterfaceOrientationLandscapeRight =  UIDeviceOrientationLandscapeLeft
24  
25 };
26  
27 注意:UIInterfaceOrientation的横屏的左边和右边跟UIDeviceOrientation刚好相反。
28  
29 2、如果需要获取设备方向变化(UIDeviceOrientation)的消息的话,需要注册UIDeviceOrientationDidChangeNotification通知。
30  
31 在注册通知时,需要先调用UIDevice的beginGeneratingDeviceOrientationNotifications方法
32  
33  [[ UIDevice  currentDevice ]  beginGeneratingDeviceOrientationNotifications ];
34  
35 [notificationCenter addObserver:self selector:@selector(deviceOrientationDidChange) name:UIDeviceOrientationDidChangeNotification object:nil];
36  
37 同时,在结束时,需要移除改通知消息
38 [ notificationCenter removeObserver :自的 名称: UIDeviceOrientationDidChangeNotification  对象:无];
39  
40 [[ UIDevice  currentDevice ]  endGeneratingDeviceOrientationNotifications ];

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值