ios设备判断

设备判断

+ (NSString *)deviceString

{

// 需要#import "sys/utsname.h"

struct utsname 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:@"iPhone3,3"])    return @"Verizon iPhone 4";

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

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

if ([deviceString isEqualToString:@"iPhone5,2"])    return @"iPhone 5 (GSM+CDMA)";

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

if ([deviceString isEqualToString:@"iPhone5,4"])    return @"iPhone 5c (GSM+CDMA)";

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

if ([deviceString isEqualToString:@"iPhone6,2"])    return @"iPhone 5s (GSM+CDMA)";

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

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

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:@"iPod5,1"])      return @"iPod Touch 5G";

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:@"iPad2,4"])      return @"iPad 2 (WiFi)";

if ([deviceString isEqualToString:@"iPad2,5"])      return @"iPad Mini (WiFi)";

if ([deviceString isEqualToString:@"iPad2,6"])      return @"iPad Mini (GSM)";

if ([deviceString isEqualToString:@"iPad2,7"])      return @"iPad Mini (GSM+CDMA)";

if ([deviceString isEqualToString:@"iPad3,1"])      return @"iPad 3 (WiFi)";

if ([deviceString isEqualToString:@"iPad3,2"])      return @"iPad 3 (GSM+CDMA)";

if ([deviceString isEqualToString:@"iPad3,3"])      return @"iPad 3 (GSM)";

if ([deviceString isEqualToString:@"iPad3,4"])      return @"iPad 4 (WiFi)";

if ([deviceString isEqualToString:@"iPad3,5"])      return @"iPad 4 (GSM)";

if ([deviceString isEqualToString:@"iPad3,6"])      return @"iPad 4 (GSM+CDMA)";

if ([deviceString isEqualToString:@"iPad4,1"])      return @"iPad Air (WiFi)";

if ([deviceString isEqualToString:@"iPad4,2"])      return @"iPad Air (Cellular)";

if ([deviceString isEqualToString:@"iPad4,3"])      return @"iPad Air";

if ([deviceString isEqualToString:@"iPad4,4"])      return @"iPad Mini 2G (WiFi)";

if ([deviceString isEqualToString:@"iPad4,5"])      return @"iPad Mini 2G (Cellular)";

if ([deviceString isEqualToString:@"iPad4,6"])      return @"iPad Mini 2G";

if ([deviceString isEqualToString:@"iPad4,7"])      return @"iPad Mini 3 (WiFi)";

if ([deviceString isEqualToString:@"iPad4,8"])      return @"iPad Mini 3 (Cellular)";

if ([deviceString isEqualToString:@"iPad4,9"])      return @"iPad Mini 3 (China)";

if ([deviceString isEqualToString:@"iPad5,3"])      return @"iPad Air 2 (WiFi)";

if ([deviceString isEqualToString:@"iPad5,4"])      return @"iPad Air 2 (Cellular)";

if ([deviceString isEqualToString:@"AppleTV2,1"])  return @"Apple TV 2G";

if ([deviceString isEqualToString:@"AppleTV3,1"])  return @"Apple TV 3";

if ([deviceString isEqualToString:@"AppleTV3,2"])  return @"Apple TV 3 (2013)";

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

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

NSLog(@"NOTE: Unknown device type: %@", deviceString);

return deviceString;

}

时间: 2024-10-09 22:14:06

ios设备判断的相关文章

iOS 设备判断 最新统计代码

- (NSString*) deviceName { struct utsname systemInfo; uname(&systemInfo); NSString* code = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding]; static NSDictionary* deviceNamesByCode = nil; if (!deviceNamesByCode) { deviceNa

判断不同IOS设备

var iOSGen = iPhone.generation; if (Debug.isDebugBuild) { Debug.Log("iPhone.generation : " + iPhone.generation); Debug.Log("SystemInfo.deviceType : " + SystemInfo.deviceType); Debug.Log("SystemInfo.deviceModel: " + SystemInfo

如何判断 ios设备的类型(iphone,ipod,ipad)

-(bool)checkDevice:(NSString*)name { NSString* deviceType = [UIDevice currentDevice].model; NSLog(@"deviceType = %@", deviceType); NSRange range = [deviceType rangeOfString:name]; return range.location != NSNotFound; } NSString * [email protecte

navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)) 判断是不是 移动设备 'ontouchstart' in window; 判断支不支

navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)) 判断是不是 移动设备 'ontouchstart' in window; 判断支不支触屏 navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)) 判断是不是 移动设备 'ontouchstart' in window; 判断支不支

利用预渲染加速iOS设备的图像显示

    最近在做一个UITableView的例子,发现滚动时的性能还不错.但来回滚动时,第一次显示的图像不如再次显示的图像流畅,出现前会有稍许的停顿感. 于是我猜想显示过的图像肯定是被缓存起来了,查了下文档后发现果然如此. 后来在<Improving Image Drawing Performance on iOS>一文中找到了一些提示:原来在显示图像时,解压和重采样会消耗很多CPU时间:而如果预先在一个bitmap context里画出图像,再缓存这个图像,就能省去这些繁重的工作了. 接着我

优化-预渲染加速iOS设备的图像显示

    最近在做一个UITableView的例子,发现滚动时的性能还不错.但来回滚动时,第一次显示的图像不如再次显示的图像流畅,出现前会有稍许的停顿感. 于是我猜想显示过的图像肯定是被缓存起来了,查了下文档后发现果然如此. 后来在<Improving Image Drawing Performance on iOS>一文中找到了一些提示:原来在显示图像时,解压和重采样会消耗很多CPU时间:而如果预先在一个bitmap context里画出图像,再缓存这个图像,就能省去这些繁重的工作了. 接着我

如何自适应ios设备大小

在编写移动端GIS程序的时候,经常要根据ios设备的大小来设置UI,以前我在ios程序中,需要定义设备的值(如:宽度和高度),如: //屏幕宽度 高度 #define kScreenWidth 320 #define kScreenHeight 548 但是如果是不同的设备,如iphone4.iphone5,甚至是ipad等设备,那么就要改变代码,非常不方便,其实ios是提供方法来解决这个问题的. 如下所示: #define ScreenHeight   [[UIScreen mainScree

iOS设备闪光灯控制

很多时候都需要在APP中控制闪光灯的开关状态,譬如扫描二维码.控制iOS设备的闪光灯代码非常简单,短短几行代码就可以搞定: AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; NSError *error; if (device.hasTorch) { // 判断设备是否有散光灯 BOOL b = [device lockForConfiguration:&error];

关于iOS设备的那些事

首先推荐一个在用的库XYQuick 地址:https://github.com/uxyheaven/XYQuick idfa: 获取方式 [ASIdentifierManager sharedManager].advertisingIdentifier.UUIDString 每个设备只有一个IDFA,不同APP在同一设备上获取IDFA的结果是一样的 设备重启不会产生新的IDFA 但IDFA存在重新生成的情况: 用户完全重置系统(设置程序 -> 通用 -> 还原 -> 还原位置与隐私) 用