7.UIDevice
来源:互联网 发布:python无限循环语句 编辑:程序博客网 时间:2024/05/16 06:22
UIDevice所做的工作就是为应用程序提供用户及设备的一切信息。
一,访问设备数据.
获取系统信息
UIDevice *currentDevice = [UIDevice currentDevice];
//获取型号
NSString *model = [currentDevice model];
//获取系统版本号
NSString *systemVersion = [currentDevice systemVersion];
//获取系统名称
NSString *strSysName = [[UIDevice currentDevice] systemName];
//获取设备名称
NSString *strName = [[UIDevice currentDevice] name];
//获得设备方向
UIInterfaceOrientation orientation = [[UIApplication sharedApplication]statusBarOrientation];
//程序启动时获取当前驱动的方向的方法
[[UIDevice currentDevice]beginGeneratingDeviceOrientationNotifications];
UIDeviceOrientation currentOrientation = [ [UIDevice currentDevice]orientation];
//currentOrientation 可以获得UIDevice 正面向上 向下方向
NSArray *languageArray = [NSLocale preferredLanguages];
//获取用户语言
NSString *language = [languageArray objectAtIndex:0];
//获取用户当前位置
NSLocale *locale = [NSLocale currentLocale];
//获取用户所在国家
NSString *country = [locale localeIdentifier];
通过NSBundle获取应用程序版本信息
NSString *appVersion = [[NSBundle mainBundle]
objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
应用程序中的info.plist文件保存着当前应用版本信息,只要利用kCFBundleVersionKey对mainBundle进行访问,即可返回正确的应用程序版本结果
NSDictionary *dicInfo = [[NSBundle mainBundle] infoDictionary];
// CFShow(dicInfo);
//获取App名称
NSString *strAppName = [dicInfo objectForKey:@"CFBundleDisplayName"];
//获取应用版本号
NSString *strAppVersion = [dicInfo objectForKey:@"CFBundleShortVersionString"];
//App应用Build版本
NSString *strAppBuild = [dicInfo objectForKey:@"CFBundleVersion"];
一,访问设备数据.
获取系统信息
UIDevice *currentDevice = [UIDevice currentDevice];
//获取型号
NSString *model = [currentDevice model];
//获取系统版本号
NSString *systemVersion = [currentDevice systemVersion];
//获取系统名称
NSString *strSysName = [[UIDevice currentDevice] systemName];
//获取设备名称
NSString *strName = [[UIDevice currentDevice] name];
//获得设备方向
UIInterfaceOrientation orientation = [[UIApplication sharedApplication]statusBarOrientation];
//程序启动时获取当前驱动的方向的方法
[[UIDevice currentDevice]beginGeneratingDeviceOrientationNotifications];
UIDeviceOrientation currentOrientation = [ [UIDevice currentDevice]orientation];
//currentOrientation 可以获得UIDevice 正面向上 向下方向
[[UIDevice currentDevice]endGeneratingDeviceOrientationNotifications];
if(orientation == 0) //Default orientation //UI is in Default (Portrait) -- this is really a just a failsafe. else if(orientation == UIInterfaceOrientationPortrait) //Do something if the orientation is in Portraitelse if(orientation == UIInterfaceOrientationLandscapeLeft) // Do something if Leftelse if(orientation == UIInterfaceOrientationLandscapeRight) //Do something if right
NSArray *languageArray = [NSLocale preferredLanguages];
//获取用户语言
NSString *language = [languageArray objectAtIndex:0];
//获取用户当前位置
NSLocale *locale = [NSLocale currentLocale];
//获取用户所在国家
NSString *country = [locale localeIdentifier];
通过NSBundle获取应用程序版本信息
NSString *appVersion = [[NSBundle mainBundle]
objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
应用程序中的info.plist文件保存着当前应用版本信息,只要利用kCFBundleVersionKey对mainBundle进行访问,即可返回正确的应用程序版本结果
NSDictionary *dicInfo = [[NSBundle mainBundle] infoDictionary];
// CFShow(dicInfo);
//获取App名称
NSString *strAppName = [dicInfo objectForKey:@"CFBundleDisplayName"];
//获取应用版本号
NSString *strAppVersion = [dicInfo objectForKey:@"CFBundleShortVersionString"];
//App应用Build版本
NSString *strAppBuild = [dicInfo objectForKey:@"CFBundleVersion"];
0 0
- 7.UIDevice
- UIDevice
- UIDevice
- UIDevice
- UIDevice
- UIDevice 用法
- UIDevice类
- [UIDevice currentDevice]
- UIKit--UIDevice
- UIDevice 类
- iOS-UIDevice
- UIDevice通知
- UIDevice通知
- UIDevice,设备信息
- UIDevice Category For Processes
- UIDevice 设备信息
- 关于UI_USER_INTERFACE_IDIOM() & UIDevice.model
- 关于UI_USER_INTERFACE_IDIOM() & UIDevice.model
- <<The C Programming Language>>学习之路-练习题参考答案 1-11
- 2048 C语言版
- 计算机视觉 监测小组
- HDU 2095
- Java split用法
- 7.UIDevice
- 黑马程序员 int.Parse()和int.TryParse()
- hdu 1715 大菲波数(大数相加)
- cocos2d-x 2个场景之间的切换。
- 堆排序
- hdu 4501 小明系列故事——买年货_二维背包
- oracle 外联结
- margin-right 一行右侧第一个元素有双边距
- QUnit 5分钟教程