• 代码如下 //获得设备型号 + (NSString *)getCurrentDeviceModel:(UIViewController *)controller {  int mib[2];  size_t len;  char *machine;  mib[0] = CTL_HW;  mib[1] = HW_MACHINE;... 

    代码如下


    //获得设备型号

    + (NSString *)getCurrentDeviceModel:(UIViewController *)controller
    {
        int mib[2];
        size_t len;
        char *machine;


        mib[0] = CTL_HW;
        mib[1] = HW_MACHINE;
        sysctl(mib, 2, NULL, &len, NULL, 0);
        machine = malloc(len);
        sysctl(mib, 2, machine, &len, NULL, 0);


        NSString *platform = [NSString stringWithCString:machine encoding:NSASCIIStringEncoding];
        free(machine);


        if ([platform isEqualToString:@"iPhone1,1"]) return @"iPhone 2G (A1203)";
        if ([platform isEqualToString:@"iPhone1,2"]) return @"iPhone 3G (A1241/A1324)";
        if ([platform isEqualToString:@"iPhone2,1"]) return @"iPhone 3GS (A1303/A1325)";
        if ([platform isEqualToString:@"iPhone3,1"]) return @"iPhone 4 (A1332)";
        if ([platform isEqualToString:@"iPhone3,2"]) return @"iPhone 4 (A1332)";
        if ([platform isEqualToString:@"iPhone3,3"]) return @"iPhone 4 (A1349)";
        if ([platform isEqualToString:@"iPhone4,1"]) return @"iPhone 4S (A1387/A1431)";
        if ([platform isEqualToString:@"iPhone5,1"]) return @"iPhone 5 (A1428)";
        if ([platform isEqualToString:@"iPhone5,2"]) return @"iPhone 5 (A1429/A1442)";
        if ([platform isEqualToString:@"iPhone5,3"]) return @"iPhone 5c (A1456/A1532)";
        if ([platform isEqualToString:@"iPhone5,4"]) return @"iPhone 5c (A1507/A1516/A1526/A1529)";
        if ([platform isEqualToString:@"iPhone6,1"]) return @"iPhone 5s (A1453/A1533)";
        if ([platform isEqualToString:@"iPhone6,2"]) return @"iPhone 5s (A1457/A1518/A1528/A1530)";
        if ([platform isEqualToString:@"iPhone7,1"]) return @"iPhone 6 Plus (A1522/A1524)";
        if ([platform isEqualToString:@"iPhone7,2"]) return @"iPhone 6 (A1549/A1586)";


        if ([platform isEqualToString:@"iPod1,1"])   return @"iPod Touch 1G (A1213)";
        if ([platform isEqualToString:@"iPod2,1"])   return @"iPod Touch 2G (A1288)";
        if ([platform isEqualToString:@"iPod3,1"])   return @"iPod Touch 3G (A1318)";
        if ([platform isEqualToString:@"iPod4,1"])   return @"iPod Touch 4G (A1367)";
        if ([platform isEqualToString:@"iPod5,1"])   return @"iPod Touch 5G (A1421/A1509)";


        if ([platform isEqualToString:@"iPad1,1"])   return @"iPad 1G (A1219/A1337)";


        if ([platform isEqualToString:@"iPad2,1"])   return @"iPad 2 (A1395)";
        if ([platform isEqualToString:@"iPad2,2"])   return @"iPad 2 (A1396)";
        if ([platform isEqualToString:@"iPad2,3"])   return @"iPad 2 (A1397)";
        if ([platform isEqualToString:@"iPad2,4"])   return @"iPad 2 (A1395+New Chip)";
        if ([platform isEqualToString:@"iPad2,5"])   return @"iPad Mini 1G (A1432)";
        if ([platform isEqualToString:@"iPad2,6"])   return @"iPad Mini 1G (A1454)";
        if ([platform isEqualToString:@"iPad2,7"])   return @"iPad Mini 1G (A1455)";


        if ([platform isEqualToString:@"iPad3,1"])   return @"iPad 3 (A1416)";
        if ([platform isEqualToString:@"iPad3,2"])   return @"iPad 3 (A1403)";
        if ([platform isEqualToString:@"iPad3,3"])   return @"iPad 3 (A1430)";
        if ([platform isEqualToString:@"iPad3,4"])   return @"iPad 4 (A1458)";
        if ([platform isEqualToString:@"iPad3,5"])   return @"iPad 4 (A1459)";
        if ([platform isEqualToString:@"iPad3,6"])   return @"iPad 4 (A1460)";


        if ([platform isEqualToString:@"iPad4,1"])   return @"iPad Air (A1474)";
        if ([platform isEqualToString:@"iPad4,2"])   return @"iPad Air (A1475)";
        if ([platform isEqualToString:@"iPad4,3"])   return @"iPad Air (A1476)";
        if ([platform isEqualToString:@"iPad4,4"])   return @"iPad Mini 2G (A1489)";
        if ([platform isEqualToString:@"iPad4,5"])   return @"iPad Mini 2G (A1490)";
        if ([platform isEqualToString:@"iPad4,6"])   return @"iPad Mini 2G (A1491)";


        if ([platform isEqualToString:@"i386"])      return @"iPhone Simulator";
        if ([platform isEqualToString:@"x86_64"])    return @"iPhone Simulator";
        return platform;
    }
    展开全文
  • 判断iOS设备类型的方法 2015-06-18 14:29:09
    - (NSString *) platformString{  // Gets a string with the device model  size_t size;   sysctlbyname("hw.machine", NULL, &size, NULL, 0);   char *machine = malloc(size);... sysctlbyn
  • 判断是否为iosAPP/androidAPP 2018-07-19 14:43:32
    //判断是否是在iosAPP中 function isIos() { var result; var rgx= new RegExp('iphone|ipad|ipod', 'i'); var rgx2 = /app\/(\d+).(\d+)?/; if(rgx.test(window.na...
  • 为什么80%的码农都做不了架构师?>>> ...
  • 判断iOS的设备型号 2014-10-11 17:55:44
    - (NSString*) doDevicePlatform {  size_t size;  int nR = sysctlbyname("hw.machine", NULL, &size, NULL, 0);  char *machine = (char *)malloc(size);... = sysc
  • 判断ios和android 2018-07-26 09:51:17
    function getPlatform() {  var ua = navigator.userAgent.toLowerCase();  if (/iphone|ipad|ipod/.test(ua)) {  platform = "ios";  WD_CLIENT_TYPE = "03";  } else if (/android/.test...
  • /*判断当前环境是Android还是iOS*/ /*var u = navigator.userAgent; // 安卓 var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; // IOS var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac...
  • Platform, } from 'react-native'; alert(JSON.stringify(Platform));android手机弹出:{"OS":"android","Version":25,"is Testing":false} 我是android7.1的 如果是...
  • 2019独角兽企业重金招聘Python工程师标准>>> ...
  • 小程序判断安卓还是IOS 2018-05-15 17:28:23
    data: { systemInfo:{}, },点击判断aaa: function(){ var that = this; wx.getSystemInfo({ success:function(res){ that.setData({ systemInfo:res, }) if(res.platform ...
  • 1、插件: cordova plugin add cordova-plugin-...2、判断是安卓平台还是ios平台: //平台: 1代表安卓 2代表IOS var deviceType = "2"; if($cordovaDevice.getPlatform() === 'Android'){  deviceType = '1'; }
  • /// 在ui中使用下面的这个判断 Theme.of(context).platform == TargetPlatform.android /// 而不是 import 'dart:io' Platform.isAndroid 然后使用VScode开启Dart: Open Dev Tools开启ios就能看到ui变化 转载于:...
  • 工具类 export default class SystemInfoUtil { static PC = "pc"; static IOS = "ios"; static ANDROID = "android"; ... * 平台 ios,andorid,pc ... static platform; /** * 基础库版本 已处理成数值7.0.0...
  • JS 使用微信提供的API wx.getSystemInfoSync(); let res = wx.getSystemInfoSync(); if(res.platform == 'ios') //ios if(res.platform == 'android') //安卓
  • **第一种:通过判断浏览器的userAgent,用正则来判断是否是ios和Android客户端。代码如下:**<script type="text/javascript"> var u = navigator.userAgent; var isAndroid = u.indexOf...
  • var Platform = require('Platform'); if (Platform.OS === 'android') { //todo }else{ //todo }
  • iOS 判断手机型号 2019-01-19 16:23:39
    引入头文件 #import <sys/sysctl.h> - (NSString*) doDevicePlatform { size_t size; int nR = sysctlbyname("hw.machine", NULL, &size, NULL, 0);... ...
  • H5前端与Android和iOS混合开发时,需要区分浏览器平台
  • var u = navigator.userAgent; var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端 var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端 ...
  • var browser = { versions: function () { var u = navigator.userAgent, app = navigator.appVersion; return {//移动终端浏览器版本信息 trident: u.indexO
1 2 3 4 5 ... 20
收藏数 7,722
精华内容 3,088