How to find iPhone/iPod Device model (3G,3GS,4,4S) by code?
本问题已经有最佳答案,请猛点这里访问。
Possible Duplicate:
Determine device (iPhone, iPod Touch) with iOS
我尝试过获得当前的设备型号名称,如3G、3GS、4、4S、iPod touch(不同代)。但是,到现在我还不能得到确切的结果。你能帮我查一下设备型号吗?在这里,我附上了我用来获取设备模型的代码。
1 2 3 | UIDevice *device = [UIDevice currentDevice]; NSString *deviceVersion = [device systemVersion];//Return 4.0.1 and 5.0.1 NSString *deviceName = [device systemName];//Return iPhone, iPod Touch |
如何获得3G、3GS、4、4S、iPod touch、iPad型号的设备?
1 2 3 4 5 6 7 8 9 10 11 | #import <sys/utsname.h> NSString* machineName() { struct utsname systemInfo; uname(&systemInfo); return [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding]; } |
结果应该是:
1 2 3 4 5 6 7 8 9 10 11 12 | @"i386" on the simulator @"iPod1,1" on iPod Touch @"iPod2,1" on iPod Touch Second Generation @"iPod3,1" on iPod Touch Third Generation @"iPod4,1" on iPod Touch Fourth Generation @"iPhone1,1" on iPhone @"iPhone1,2" on iPhone 3G @"iPhone2,1" on iPhone 3GS @"iPad1,1" on iPad @"iPad2,1" on iPad 2 @"iPhone3,1" on iPhone 4 @"iPhone4,1" on iPhone 4S |
Girhub上有一个图书馆可以做到这一点。看到这个链接:
https://github.com/erica/uidevice-extension