http://hi.baidu.com/myyuchong/item/77f2f750a9e9553433e0a985
//@"iPad1,1"
//@"iPad2,1"
//@"i386"
逗号后面数字解释:(i386是指模拟器)
1-WiFi版
2-GSM/WCDMA 3G版
3-CDMA版
AppleTV(2G) (AppleTV2,1)
iPad (iPad1,1)
iPad2,1 (iPad2,1)Wifi版
iPad2,2 (iPad2,2)GSM3G版
iPad2,3 (iPad2,3)CDMA3G版
iPhone (iPhone1,1)
iPhone3G (iPhone1,2)
iPhone3GS (iPhone2,1)
iPhone4 (iPhone3,1)
iPhone4(vz) (iPhone3,3)iPhone4 CDMA版
iPhone4S (iPhone4,1)
iPodTouch(1G) (iPod1,1)
iPodTouch(2G) (iPod2,1)
iPodTouch(3G) (iPod3,1)
iPodTouch(4G) (iPod4,1)
另外放两个固件下载地址:
http://apple.178.com/ios/
http://ipad.sj.91.com/ios/
判断ipad/iphone
---------------
NSString *nibTitle = @"PadContent"; //iPad
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
//iPhone
nibTitle = @"PhoneContent";
}
----------
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
CGSize result = [[UIScreen mainScreen] bounds].size;
if(result.height == 480.f)
{
return @"ViewController";
}
else
{
return @"ViewController-iPhone5";
}
}
return @"ViewController-iPad";
------------------
NSString *dangqianshebei=[NSString stringWithFormat:@"%@",[[UIScreen mainScreen]preferredMode]];
NSRange this=[dangqianshebei rangeOfString:@"2048"];
if (this.location != NSNotFound) {
NSLog(@"ipad3");
}else {
this=[dangqianshebei rangeOfString:@"1024"];
if (this.location != NSNotFound) {
NSLog(@"ipad2");
}else {
this=[dangqianshebei rangeOfString:@"960"];
if (this.location != NSNotFound) {
NSLog(@"iphone高清");
}else {
this=[dangqianshebei rangeOfString:@"480"];
if (this.location != NSNotFound) {
NSLog(@"iphone小屏");
}else {
NSLog(@"其他");
}
}
}
}
---------
请注意,如果你在创建项目的时候只支持一种设备类型,上面的语句将始终返回选定ios设备类型,如项目只支持iPhone,即使在iPad上运行,前述的代码依然返回iPhone设备类型。
执行环境
我们可以从 UIDevice 的属性 model 得到在现在执行的环境。
NSString *modelname = [[UIDevice currentDevice]model];
if ([modelname isEqualToString:@"iPhone"]) {
// iPhone
}
if ([modelname isEqualToString:@"IPod Touch"]) {
// iPod touch}
if ([modelname isEqualToString:@"iPhone Simulator"]) {
// iPhone Simulator
}
或者也可以这样:
#import <TargetConditionals.h>
#if TARGET_OS_IPHONE
// iPhone Device
#endif
#if TARGET_IPHONE_SIMULATOR
// iPhone Simulator
#endif
#if !TARGET_IPHONE_SIMULATOR
// iPhone Device
#endif
iPhone 机器版本的区分
可以通过 uname 函数取得当前机器的版本。
struct utsname u;
uname(&u);
NSString *machine = [NSStringstringWithCString:u.machine];
if ([machine isEqualToString:@"iPhone1,1"]) {
// iPhone 1G
}
if ([machine isEqualToString:@"iPhone1,2"]) {
// iPhone 3G
}
if ([machine isEqualToString:@"iPhone2,1"]) {
// iPhone 3GS
}
if ([machine isEqualToString:@"iPod1,1"]) {
// iPod touch 1G
}
if ([machine isEqualToString:@"iPod2,1"]) {
// iPod touch 2G
}
if([machine isEqualToString:@"iPod3,1"]) {
// iPod touch Late2009
}
iPhone OS 版本区分
可以使用 UIDevice 的属性 systemVersion 来得到。
NSString *osversion = [UIDevice currentDevice].systemVersion;
if ([osversion isEqualToString:@"2.1"]) {
// iPhone
}
if ([osversion isEqualToString:@"2.2.1"])
{
// iPod touch
}
if ([osversion isEqualToString:@"3.0"]) {
// iPhone Simulator
}
=================
@@@@@
苹果的每个产品都有几个类型,从iphone到ipod、ipad,而每个产品又有几个类型,从iphone2G到iphone5,从iPod touch1到iPod touch5,从ipad1到ipad4,只有你想不到的,没有人家做不到的。
但是在做ios开发中如何检测这些类型呢?下边的方法就是CSDN问答中给出的方法,原问题见:http://ask.csdn.net/questions/997
#include <sys/sysctl.h>
http://ask.csdn.net/questions/997