Including the opponent system version of the judgment, the phone hardware judgment, the specific model of the phone to judge.
#import "RootViewController.h"//to determine the model of the phone-(nsstring*) devicestring Add header file#import "sys/utsname.h"- (void) viewdidload{[Super Viewdidload]; //Do any additional setup after loading the view.NSLog (@"----systemversion---%@", [self systemversion]); if([self isIphone5]) {NSLog (@"----is Iphone5---"); }Else{NSLog (@"----NOT a Iphone5---"); } NSLog (@"----devicestring---%@", [self devicestring]); NSLog (@"---getdevicemodel---%@--", [self Getdevicemodel]);}#pragma-mark-system version judgment (i.e. ios7.0,ios6.0 's judgment) output: 7.1-(nsstring*) systemversion{return[[Uidevice Currentdevice] systemversion];}#pragma-mark-Determine if the phone is iphone5 (that is, in Iphon4,iphone5)-(BOOL) isiphone5{if([UIScreen instancesrespondtoselector: @selector (CurrentMode)]) {returnCgsizeequaltosize (Cgsizemake (640,1136), [[UIScreen mainscreen] currentmode].size); } Else { returnNO; }}#pragma-mark-Judging the phone model abbreviated version//need #import "Sys/utsname.h"-(NSString *) getdevicemodel{structutsname u; Uname (&u); NSString*modelversion = [NSString stringWithFormat:@"%s", U.machine]; returnmodelversion;}#pragma-mark-Determine the model detail version of the phone//determine the model of the phone//need #import "Sys/utsname.h"-(nsstring*) devicestring{structUtsname SystemInfo; Uname (&systemInfo); NSString*devicestring =[NSString stringWithCString:systemInfo.machine encoding:nsutf8stringencoding]; if([devicestring isequaltostring:@"iphone1,1"])return @"IPhone 1G"; if([devicestring isequaltostring:@"iphone1,2"])return @"IPhone 3G"; if([devicestring isequaltostring:@"iphone2,1"])return @"IPhone 3GS"; if([devicestring isequaltostring:@"iphone3,1"])return @"IPhone 4"; if([devicestring isequaltostring:@"iphone4,1"])return @"IPhone 4S"; if([devicestring isequaltostring:@"iphone5,2"])return @"IPhone 5"; if([devicestring isequaltostring:@"iphone3,2"])return @"Verizon IPhone 4"; if([devicestring isequaltostring:@"ipod1,1"])return @"iPod Touch 1G"; if([devicestring isequaltostring:@"ipod2,1"])return @"iPod Touch 2G"; if([devicestring isequaltostring:@"ipod3,1"])return @"iPod Touch 3G"; if([devicestring isequaltostring:@"ipod4,1"])return @"iPod Touch 4G"; if([devicestring isequaltostring:@"ipad1,1"])return @"IPad"; if([devicestring isequaltostring:@"ipad2,1"])return @"IPad 2 (WiFi)"; if([devicestring isequaltostring:@"ipad2,2"])return @"IPad 2 (GSM)"; if([devicestring isequaltostring:@"ipad2,3"])return @"IPad 2 (CDMA)"; if([devicestring isequaltostring:@"i386"])return @"Simulator"; if([devicestring isequaltostring:@"x86_64"])return @"Simulator"; NSLog (@"note:unknown Device type:%@", devicestring); returndevicestring;}