月圆之夜,紫禁之巅,一剑西来,天外飞仙。

0%

iOS 判断手机型号

判断手机型号代码如下:

1
#import <sys/utsname.h>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#pragma mark -- 判断手机型号
+(NSString*)judgeIphoneType {

struct utsname systemInfo;

uname(&systemInfo);

NSString * phoneType = [NSString stringWithCString: systemInfo.machine encoding:NSASCIIStringEncoding];

// simulator 模拟器

if ([phoneType isEqualToString:@"i386"]) return @"Simulator";

if ([phoneType isEqualToString:@"x86_64"]) return @"Simulator";

// 常用机型 不需要的可自行删除

if([phoneType isEqualToString:@"iPhone1,1"]) return @"iPhone 2G";

if([phoneType isEqualToString:@"iPhone1,2"]) return @"iPhone 3G";

if([phoneType isEqualToString:@"iPhone2,1"]) return @"iPhone 3GS";

if([phoneType isEqualToString:@"iPhone3,1"]) return @"iPhone 4";

if([phoneType isEqualToString:@"iPhone3,2"]) return @"iPhone 4";

if([phoneType isEqualToString:@"iPhone3,3"]) return @"iPhone 4";

if([phoneType isEqualToString:@"iPhone4,1"]) return @"iPhone 4S";

if([phoneType isEqualToString:@"iPhone5,1"]) return @"iPhone 5";

if([phoneType isEqualToString:@"iPhone5,2"]) return @"iPhone 5";

if([phoneType isEqualToString:@"iPhone5,3"]) return @"iPhone 5c";

if([phoneType isEqualToString:@"iPhone5,4"]) return @"iPhone 5c";

if([phoneType isEqualToString:@"iPhone6,1"]) return @"iPhone 5s";

if([phoneType isEqualToString:@"iPhone6,2"]) return @"iPhone 5s";

if([phoneType isEqualToString:@"iPhone7,1"]) return @"iPhone 6 Plus";

if([phoneType isEqualToString:@"iPhone7,2"]) return @"iPhone 6";

if([phoneType isEqualToString:@"iPhone8,1"]) return @"iPhone 6s";

if([phoneType isEqualToString:@"iPhone8,2"]) return @"iPhone 6s Plus";

if([phoneType isEqualToString:@"iPhone8,4"]) return @"iPhone SE";

if([phoneType isEqualToString:@"iPhone9,1"]) return @"iPhone 7";

if([phoneType isEqualToString:@"iPhone9,2"]) return @"iPhone 7 Plus";

if([phoneType isEqualToString:@"iPhone10,1"]) return @"iPhone 8";

if([phoneType isEqualToString:@"iPhone10,4"]) return @"iPhone 8";

if([phoneType isEqualToString:@"iPhone10,2"]) return @"iPhone 8 Plus";

if([phoneType isEqualToString:@"iPhone10,5"]) return @"iPhone 8 Plus";

if([phoneType isEqualToString:@"iPhone10,3"]) return @"iPhone X";

if([phoneType isEqualToString:@"iPhone10,6"]) return @"iPhone X";

if([phoneType isEqualToString:@"iPhone11,8"]) return @"iPhone XR";

if([phoneType isEqualToString:@"iPhone11,2"]) return @"iPhone XS";

if([phoneType isEqualToString:@"iPhone11,4"]) return @"iPhone XS Max";

if([phoneType isEqualToString:@"iPhone11,6"]) return @"iPhone XS Max";

return phoneType;

}