iOS 获取设备型号

释放双眼,带上耳机,听听看~!
#import <sys/utsname.h> // 头文件导入后 直接调用
struct utsname systemInfo;
+ (NSString *)iphoneType {
uname(&systemInfo);
NSString *phoneType = [NSString stringWithCString:systemInfo.machine encoding:NSASCIIStringEncoding];
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;
}

人已赞赏
iOS文章

ios view部分圆角

2020-4-30 4:16:49

iOS文章

iOS 关于iOS13 tabbar item的字体颜色问题 隐藏黑线 修改tabbar高度.....

2020-4-30 5:32:05

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
有新消息 消息中心
搜索