美文网首页iOS基础
最近判断iPhone机型(包含iphone11)

最近判断iPhone机型(包含iphone11)

作者: Wayne_王 | 来源:发表于2019-10-31 17:12 被阅读0次

    声明:iphone11 的判断目前是基于 模拟器获取的,没有真迹测试,不保证准确率(但应该没问题)。会持续更新

    1.先导入:#import <sys/utsname.h>

    //获取当前手机型号

    +(NSString*)getCurrentIPhonePlatform{

        structutsnamesystemInfo;

        uname(&systemInfo);

        NSString *deviceString = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];

        //(公司的应用不支持iPad)

        // iPhone

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        if([deviceStringisEqualToString:@"iPhone8,3"])    return@"iPhone SE";

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

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

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

        if([deviceStringisEqualToString:@"iPhone9,3"])    return@"iPhone 7";

        if([deviceStringisEqualToString:@"iPhone9,4"])    return@"iPhone 7 Plus";

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

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

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

        if([deviceStringisEqualToString:@"iPhone10,4"])  return@"iPhone 8 GSM";

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

        if([deviceStringisEqualToString:@"iPhone10,6"])  return@"iPhone X GSM";

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

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

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

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

        if([deviceStringisEqualToString:@"iPhone12,1"])  return@"iPhone 11";

        if ([deviceString isEqualToString:@"iPhone12,3"])  return @"iPhone 11 Pro";

        if ([deviceString isEqualToString:@"iPhone12,5"])  return @"iPhone 11 Pro Max";

        returndeviceString;

    }

    相关文章

      网友评论

        本文标题:最近判断iPhone机型(包含iphone11)

        本文链接:https://www.haomeiwen.com/subject/lqkeuctx.html