zoukankan      html  css  js  c++  java
  • 获取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

  • 相关阅读:
    可搜索的下拉框
    Vue 父组件调用子组件的方法
    vue中异步函数async和await的用法
    用配置文件的方法发送axios请求
    vue中 localStorage的使用方法(详解)
    下拉框 组件的使用
    遇到不懂的记录
    做测试平台可能会用到的东西
    下拉框 v-for循环拿值的方法
    ant 自定义遮罩
  • 原文地址:https://www.cnblogs.com/pocket-mood/p/4476903.html
Copyright © 2011-2022 走看看