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

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

 

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

经过这个实例,能够得到设备的相关信息(包括系统名称,版本号,设备模式等等)。文档

也能够使用使用该实例来监测设备的特征(好比物理方向)。it

 

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

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

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

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

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

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

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

 

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

    [UIDevice currentDevice].batteryMonitoringEnabled = YES;

    double deviceLevel = [UIDevice currentDevice].batteryLevel;

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

相关文章
相关标签/搜索