获取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

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。