星空网 > 软件开发 > 操作系统

检测手机朝向UIDevice

- (void)viewDidLoad{  [super viewDidLoad];  //检测设备朝向使用UIDevice,beginGeneratingDeviceOrientationNotifications方法向通知中心发送朝向信息  [[UIDevice currentDevice]beginGeneratingDeviceOrientationNotifications];  //建立通知中心  [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:nil];}

-(void)orientationChanged:(NSNotification *)notification{  UIDeviceOrientation orientation=[[UIDevice currentDevice]orientation];  switch (orientation) {    case UIDeviceOrientationFaceUp:      NSLog(@"设备正面朝上");      break;      case UIDeviceOrientationFaceDown:      NSLog(@"设备正面朝下");      break;      case UIDeviceOrientationPortrait:      NSLog(@"设备处于正常朝向,主屏幕按钮在下方");      break;      case UIDeviceOrientationPortraitUpsideDown:      NSLog(@"设备处于纵向,主屏幕按钮在上方");      break;      case UIDeviceOrientationLandscapeLeft:      NSLog(@"设备侧立,左边朝下");      break;      case UIDeviceOrientationLandscapeRight:      NSLog(@"设备侧立,右边朝下");      break;    default:      break;  }}

附:检测手机版本信息使用的也是UIDevice.

  //获取硬件信息  UIDevice *device=[UIDevice currentDevice];  //输出版本号  NSLog(@"%@",device.systemVersion);

 

 
 



原标题:检测手机朝向UIDevice

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

“宠物抛球器”在美国市场的(发明专利)侵权预警及规避办法612:https://www.kjdsnews.com/a/1696235.html
红海对集装箱的影响比油轮、散货船大得多:https://www.kjdsnews.com/a/1696236.html
涨价预警、航线中断,卖家如何高效备货?:https://www.kjdsnews.com/a/1696237.html
ofo戴威二次创业败走美国,咖啡馆仅剩一家:https://www.kjdsnews.com/a/1696238.html
亚马逊六款,地插蘑菇灯---美国专利侵权预警:https://www.kjdsnews.com/a/1696239.html
中国电商海外突围!TikTok亿级流量强势入局:https://www.kjdsnews.com/a/1696240.html
SEOer必须掌握的五大软技能:https://www.kjdsnews.com/a/1836597.html
“有几个独角兽真的值10亿美金?”:https://www.kjdsnews.com/a/1836598.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流