搜索
您的当前位置:首页正文

在IOS中获取设备信息相关

来源:知库网

UIDevice提供了多种属性、类函数及状态通知,帮助我们全方位了解设备状况。从检测电池电量到定位设备与临近感应,UIDevice所做的工作就是为应用程序提供用户及设备的一些信息。UIDevice类还能够收集关于设备的各种具体细节,例如机型及iOS版本等。其中大部分属性都对开发工作具有积极的辅助作用。下面的代码简单的使用UIDevice获取手机属性。

//    [[UIDevice currentDevice] systemName]; // 系统名

//    [[UIDevice currentDevice] systemVersion]; //版本号

//    [[UIDevice currentDevice] model]; //类型,模拟器,真机

//    [[UIDevice currentDevice] uniqueIdentifier]; //唯一识别码

//    [[UIDevice currentDevice] name]; //设备名称

//    [[UIDevice currentDevice] localizedModel]; // 本地模式

//设备相关信息的获取

NSString *strName = [[UIDevice currentDevice] name];

NSLog(@"设备名称:%@", strName);//e.g. "My iPhone"

NSString *strId = [[UIDevice currentDevice] uniqueIdentifier];

NSLog(@"设备唯一标识:%@", strId);//UUID,5.0后不可用

NSString *strSysName = [[UIDevice currentDevice] systemName];

NSLog(@"系统名称:%@", strSysName);// e.g. @"iOS"

NSString *strSysVersion = [[UIDevice currentDevice] systemVersion];

NSLog(@"系统版本号:%@", strSysVersion);// e.g. @"4.0"

NSString *strModel = [[UIDevice currentDevice] model];

NSLog(@"设备模式:%@", strModel);// e.g. @"iPhone", @"iPod touch"

NSString *strLocModel = [[UIDevice currentDevice] localizedModel];

NSLog(@"本地设备模式:%@", strLocModel);// localized version of model //地方型号  (国际化区域名称)

NSString* phoneModel = [[UIDevice currentDevice] model];

NSLog(@"手机型号: %@",phoneModel );   //手机型号

Top