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

posted @ 2015-05-04 18:14  pocket_live  阅读(257)  评论(0编辑  收藏  举报