获取iOS设备信息 iOS 2015年 01月16日 由于最近要做iPhone6和iPhone6+的适配工作,所以难免会需要对设备型号进行判断,就借此机会总结下判断设备的方法 获取iOS设备信息 1.根据屏幕宽度大小进行判断 #define iPhone6 ([UIScreen instancesRespondToSelector:@selector( currentMode )] ? CGSizeEqualToSize(CGSizeMake(750, 1334), [[UIScreen mainScreen] currentMode].size) : NO) #define iPhone6Plus ([UIScreen instancesRespondToSelector:@selector( currentMode )] ? CGSizeEqualToSize(CGSizeMake(1242, 2208), [[UIScreen mainScreen] currentMode].size) : NO) 2.读取设备信息进行判断 #import "sys/utsname.h" - (NSString *)deviceModel { struct utsname systemInfo; uname(&systemInfo); return [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding]; } 3.简单的读取设备model [UIDevice currentDevice].model; 其中第三种方法是调用上层API,比较推荐使用。如果需要比较详细的设备制式信息,推荐第二种方法,关于对照表如下: @"i386" :@"Simulator", @"iPod1,1" :@"iPod Touch", // (Original) @"iPod2,1" :@"iPod Touch", // (Second Generation) @"iPod3,1" :@"iPod Touch", // (Third Generation) @"iPod4,1" :@"iPod Touch", // (Fourth Generation) @"iPhone1,1" :@"iPhone", // (Original) @"iPhone1,2" :@"iPhone", // (3G) @"iPhone2,1" :@"iPhone", // (3GS) @"iPad1,1" :@"iPad", // (Original) @"iPad2,1" :@"iPad 2", // @"iPad3,1" :@"iPad", // (3rd Generation) @"iPhone3,1" :@"iPhone 4", // @"iPhone4,1" :@"iPhone 4S", // @"iPhone5,1" :@"iPhone 5", // (model A1428, AT&T/Canada) @"iPhone5,2" :@"iPhone 5", // (model A1429, everything else) @"iPad3,4" :@"iPad", // (4th Generation) @"iPad2,5" :@"iPad Mini", // (Original) @"iPhone5,3" :@"iPhone 5c", // (model A1456, A1532 | GSM) @"iPhone5,4" :@"iPhone 5c", // (model A1507, A1516, A1526 (China), A1529 | Global) @"iPhone6,1" :@"iPhone 5s", // (model A1433, A1533 | GSM) @"iPhone6,2" :@"iPhone 5s", // (model A1457, A1518, A1528 (China), A1530 | Global) @"iPad4,1" :@"iPad Air", // 5th Generation iPad (iPad Air) - Wifi @"iPad4,2" :@"iPad Air", // 5th Generation iPad (iPad Air) - Cellular @"iPad4,4" :@"iPad Mini", // (2nd Generation iPad Mini - Wifi) @"iPad4,5" :@"iPad Mini" // (2nd Generation iPad Mini - Cellular) 详细可以参见设备制式对照表