• 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(@"不支持多任务!!!");    }
  • 相关阅读:
    python的性能了解
    工作记录01/17/11
    继承或者重写django的user model?
    dunder=double underscore
    ipython应该是个好的命令行式的python ide,不过现在没时间折腾。
    django的settings如何在不同环境下进行切换
    pythonic实践
    关于递归函数的简单认识
    数据结构(C语言版)链表相关操作算法的代码实现
    数据结构(C语言版)顺序栈相关算法的代码实现
  • 原文地址:https://www.cnblogs.com/fengmin/p/5548420.html
Copyright © 2020-2023  润新知