设备类型判断 获取设备相关信息
2014-04-08 17:10
253 查看
真机与模拟器判断+设备类型判断
#if defined(TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR
NSLog(@" on simulator");
#else
NSLog(@"not on simulator");
#endif
注意:TARGET_OS_IPHONE在真机和模拟器上都是1
设备类型判断方法有两种:
1. UI_USER_INTERFACE_IDIOM() 进行区分(ios 3.2以上),但是无法区分iphone和ipod
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
//设备为ipad
} else {
//设备为iphone 或 ipod
}
2. 使用 UIDevice.model 进行区分 (ios 2.0 >=)
NSString *deviceType = [UIDevice currentDevice].model;
if([deviceType isEqualToString:@"iPhone"]) {
//iPhone
}else if([deviceType isEqualToString:@"iPod touch"]) {
//iPod Touch
}else {
//iPad
}
五、获取设备相关信息
//软件信息
NSLog(@"sysname=%@",[[UIDevice currentDevice] systemName]);// 系统名
NSLog(@"systemVersion=%@",[[UIDevice currentDevice] systemVersion]); //版本号
NSLog(@"model=%@",[[UIDevice currentDevice] model]); //类型(ipad、ipod、iphone)而[[UIDevice currentDevice] userInterfaceIdiom]只能判断iphone和ipad
NSLog(@"olduuid=%@",[[UIDevice currentDevice] uniqueIdentifier]); //唯一识别码 ios5.0开始deprecated
NSLog(@"name=%@",[[UIDevice currentDevice] name]); //设备名称
NSLog(@"localizedModel=%@",[[UIDevice currentDevice] localizedModel]); // 本地模式
NSLog(@"ios6UUID=%@",[[[UIDevice currentDevice] identifierForVendor] UUIDString]);//ios6.0开始available
----------注:以下内容未测试,摘自/article/4832924.html---------------
// 硬件信息
[UIDevice platform];//平台
[UIDevice cpuFrequency]];//cpu信息
UIDevice busFrequency]];//总线
[UIDevice totalMemory]];//总内存
UIDevice userMemory]];//已经使用的内存
-----------------------------------------------------------------------------------------------------------------------------
//App信息
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
CFShow(infoDictionary);//所有plist内容
// app名称
NSString *app_Name = [infoDictionary objectForKey:@"CFBundleDisplayName"];
// app版本
NSString *app_Version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
// app build版本
NSString *app_build = [infoDictionary objectForKey:@"CFBundleVersion"]; 判断是否有照相机
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
NSLog(@"有");
else
NSLog(@"没有");六、针对不同分辨率的设备,程序员只需要做三件事:
1.提供app高清图标;
2.UI图片素材@2x.png;
3.从网络下载适配的图片(判断条件[[UIScreen mainScreen] respondsToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] == 2)
-所有的iPhone、iPod Touch设备的 Point分辨率都是 320×480,也就是逻辑分辨率都一致,保证了App不需要修改也能正常的在高像素分辨率上运行,只是原来App中的图片会被拉升后显示,影响美观,没有发挥retina的优势。
-程序内所有的GCRectMake都是逻辑分辨率,不影响位置和大小!做游戏开发最有用,普通app影响不大
-问题:如何进行相对布局???(6.0之前有autoResizeMask,autoresizing 6.0可使用与android相对布局类似的autoLayout)
#if defined(TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR
NSLog(@" on simulator");
#else
NSLog(@"not on simulator");
#endif
注意:TARGET_OS_IPHONE在真机和模拟器上都是1
设备类型判断方法有两种:
1. UI_USER_INTERFACE_IDIOM() 进行区分(ios 3.2以上),但是无法区分iphone和ipod
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
//设备为ipad
} else {
//设备为iphone 或 ipod
}
2. 使用 UIDevice.model 进行区分 (ios 2.0 >=)
NSString *deviceType = [UIDevice currentDevice].model;
if([deviceType isEqualToString:@"iPhone"]) {
//iPhone
}else if([deviceType isEqualToString:@"iPod touch"]) {
//iPod Touch
}else {
//iPad
}
五、获取设备相关信息
//软件信息
NSLog(@"sysname=%@",[[UIDevice currentDevice] systemName]);// 系统名
NSLog(@"systemVersion=%@",[[UIDevice currentDevice] systemVersion]); //版本号
NSLog(@"model=%@",[[UIDevice currentDevice] model]); //类型(ipad、ipod、iphone)而[[UIDevice currentDevice] userInterfaceIdiom]只能判断iphone和ipad
NSLog(@"olduuid=%@",[[UIDevice currentDevice] uniqueIdentifier]); //唯一识别码 ios5.0开始deprecated
NSLog(@"name=%@",[[UIDevice currentDevice] name]); //设备名称
NSLog(@"localizedModel=%@",[[UIDevice currentDevice] localizedModel]); // 本地模式
NSLog(@"ios6UUID=%@",[[[UIDevice currentDevice] identifierForVendor] UUIDString]);//ios6.0开始available
----------注:以下内容未测试,摘自/article/4832924.html---------------
// 硬件信息
[UIDevice platform];//平台
[UIDevice cpuFrequency]];//cpu信息
UIDevice busFrequency]];//总线
[UIDevice totalMemory]];//总内存
UIDevice userMemory]];//已经使用的内存
-----------------------------------------------------------------------------------------------------------------------------
//App信息
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
CFShow(infoDictionary);//所有plist内容
// app名称
NSString *app_Name = [infoDictionary objectForKey:@"CFBundleDisplayName"];
// app版本
NSString *app_Version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
// app build版本
NSString *app_build = [infoDictionary objectForKey:@"CFBundleVersion"]; 判断是否有照相机
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
NSLog(@"有");
else
NSLog(@"没有");六、针对不同分辨率的设备,程序员只需要做三件事:
1.提供app高清图标;
2.UI图片素材@2x.png;
3.从网络下载适配的图片(判断条件[[UIScreen mainScreen] respondsToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] == 2)
-所有的iPhone、iPod Touch设备的 Point分辨率都是 320×480,也就是逻辑分辨率都一致,保证了App不需要修改也能正常的在高像素分辨率上运行,只是原来App中的图片会被拉升后显示,影响美观,没有发挥retina的优势。
-程序内所有的GCRectMake都是逻辑分辨率,不影响位置和大小!做游戏开发最有用,普通app影响不大
-问题:如何进行相对布局???(6.0之前有autoResizeMask,autoresizing 6.0可使用与android相对布局类似的autoLayout)
相关文章推荐
- 获取当前设备类型和相关信息
- MFC获取窗体在设备上的相关信息,位置,设备信息等
- iOS获取设备型号、设备类型等信息
- 获取iOS设备的相关信息
- iOS获取设备型号、设备类型等信息
- UIDevice 获取设备相关信息备忘
- 获取设备相关信息
- iOS开发小技巧 获取当前设备/应用程序相关信息
- iOS获取设备型号、设备类型等信息
- Unity3D的SystemInfo类,用于获取运行设备硬件信息(CPU、显卡、类型等)
- JS获取浏览器信息/判断浏览器类型
- 根据mac地址+deviceid获取设备唯一编码 获取手机及SIM卡相关信息
- iOS获得设备相关信息,获取app相关信息
- 获取iPhone的屏幕分辨率以及判断设备类型
- iOS 设备获取设备相关信息
- 162,获取设备的宽,高,类型等信息
- iOS判断判断设备类型信息
- 运行时判web容器类型及获取web容器相关信息
- JS 判断浏览器类型,获取位置信息,让手机震动
- Python中继承、多态、多继承、判断类型、json.load()解析、获取/设置对象信息