UIDevice 系统信息详解

获取当前设备

 

    //获取当前设备    UIDevice *dev = [UIDevice currentDevice];

 

设备和系统基本信息

 

    NSLog(@"设备名称:%@", dev.name);  
    NSLog(@"设备类型:%@", dev.model);  
    NSLog(@"本地化模式:%@", dev.localizedModel); 
    NSLog(@"系统名称:%@", dev.systemName);   
    NSLog(@"系统版本:%@", dev.systemVersion);   
    NSLog(@"设备朝向:%ld", dev.orientation); 
    NSLog(@"UUID:%@", dev.identifierForVendor.UUIDString);

 

设备类型判断

 

    //判断设备种类
    if (dev.userInterfaceIdiom == UIUserInterfaceIdiomPhone) {    
         NSLog(@"iPhone 设备");    }else if(dev.userInterfaceIdiom == UIUserInterfaceIdiomPad)    {      
        NSLog(@"iPad 设备");    } else if (dev.userInterfaceIdiom == UIUserInterfaceIdiomTV)    {    
        NSLog(@"Apple TV设备");    } else    {    
        NSLog(@"未知设备!!");    }

 

电池相关信息

 

    //设置电池是否被监视
    dev.batteryMonitoringEnabled = YES;    //判断当前电池状态
    if (dev.batteryState == UIDeviceBatteryStateUnknown) {   
        NSLog(@"UnKnow");    }else if (dev.batteryState == UIDeviceBatteryStateUnplugged){  
        NSLog(@"未充电");    }else if (dev.batteryState == UIDeviceBatteryStateCharging){
        NSLog(@"正在充电,电量未满");    }else if (dev.batteryState == UIDeviceBatteryStateFull){  
         NSLog(@"正在充电,电量已满");    }    //当前电量等级 [0.0, 1.0]    NSLog(@"%f",dev.batteryLevel);      UIDeviceBatteryLevelDidChangeNotification    //电池状态改变通知    UIDeviceBatteryStateDidChangeNotification    //以上两个通知需在 batteryMonitoringEnabled 设置为YES的情况下有效

 

红外线感应

 

    //开启红外感应-- 用于检测手机是否靠近面部
    dev.proximityMonitoringEnabled = YES;  
   if (dev.proximityState == YES) {  
        NSLog(@"靠近面部");    } else    {      
        NSLog(@"没有靠近");    }

 

多任务环境监测

 

    //判断当前系统是否支持多任务
    if (dev.isMultitaskingSupported == YES) { 
       NSLog(@"支持多任务!!!");    } else{    
       NSLog(@"不支持多任务!!!");    }

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值