• 获取iOS系统版本和设备的电量


    获取iOS系统版本 --- UIDevice的使用

     

    UIDevice类是一个单例,其唯一的实例( [UIDevice currentDevice] ) 代表了当前使用的设备。

    通过这个实例,可以获得设备的相关信息(包括系统名称,版本号,设备模式等等)。

    也可以使用使用该实例来监测设备的特征(比如物理方向)。

     

    NSString *strName = [[UIDevice currentDevice] name]; // 设备名称 

    NSString *strId = [[UIDevice currentDevice] uniqueIdentifier]; // 设备ID ,设备的惟一标识号

    NSString *strSysName = [[UIDevice currentDevice] systemName]; // 设备系统名称 

    NSString *strSysVersion = [[UIDevice currentDevice] systemVersion]; // 设备系统版本号 

    NSString *strModel = [[UIDevice currentDevice] model]; // 设备模式 如:iPhone或者iPod touch

    NSString *strLocModel = [[UIDevice currentDevice] localizedModel]; // 本地设备模式 

    float version = [[[UIDevice currentDevice] systemVersion] floatValue]; // 设备的iOS 版本号

     

    获取设备的电量,苹果官方文档给了接口

        [UIDevice currentDevice].batteryMonitoringEnabled = YES;

        double deviceLevel = [UIDevice currentDevice].batteryLevel;

    每次获取的数值都是递增0.05

  • 相关阅读:
    过度效果
    JQ 滚动图片
    清除Css中select的下拉箭头样式
    利用原生 js 模拟出 JSON.parse 和 JSON.stringify
    利用 qrcode 在图片生成二维码
    JavaScript--正则表达式
    2、less的用法
    模拟select下拉框之多选(数据源采用模拟Ajax数据--原创)
    模拟 ES6 SET 数组去重
    前端方式导入导出xlsx
  • 原文地址:https://www.cnblogs.com/pocket-mood/p/4476903.html
Copyright © 2020-2023  润新知