使用下一个代码,我将获得设备类型。我也想知道iPad的所有设备类型(Air
和mini
)。
是否有包含所有新设备的新列表? 谢谢。
- (NSString*)getDeviceType
{
NSString *hardware = [self hardwareString];
if ([hardware isEqualToString:@"iPad3,2"]) return @"iPad 3 (GSM+CDMA)";
if ([hardware isEqualToString:@"iPad3,3"]) return @"iPad 3";
if ([hardware isEqualToString:@"iPad3,4"]) return @"iPad 4 (WiFi)";
if ([hardware isEqualToString:@"iPad3,5"]) return @"iPad 4";
if ([hardware isEqualToString:@"iPad3,6"]) return @"iPad 4 (GSM+CDMA)";
}
- (NSString*)hardwareString
{
size_t size = 100;
char *hw_machine = malloc(size);
int name[] = {CTL_HW,HW_MACHINE};
sysctl(name, 2, hw_machine, &size, NULL, 0);
NSString *hardware = [NSString stringWithUTF8String:hw_machine];
free(hw_machine);
return hardware;
}
答案 0 :(得分:1)
我有最新的Mini Retina(日语,4G,型号A1490),它在iTunes中显示iPad4,5。
编辑:@larme链接似乎很完美https://github.com/InderKumarRathore/UIDevice-Hardware/blob/master/UIDevice%2BHardware.m答案 1 :(得分:1)
这是我正在寻找的新设备。
if ([modelIdentifier isEqualToString:@"iPad4,1"]) return @"iPad Air (WiFi)";
if ([modelIdentifier isEqualToString:@"iPad4,2"]) return @"iPad Air (Cellular)";
// iPad Mini http://theiphonewiki.com/wiki/IPad_mini
if ([modelIdentifier isEqualToString:@"iPad2,5"]) return @"iPad mini 1G (WiFi)";
if ([modelIdentifier isEqualToString:@"iPad2,6"]) return @"iPad mini 1G (GSM)";
if ([modelIdentifier isEqualToString:@"iPad2,7"]) return @"iPad mini 1G (Global)";
if ([modelIdentifier isEqualToString:@"iPad4,4"]) return @"iPad mini 2G (WiFi)";
if ([modelIdentifier isEqualToString:@"iPad4,5"]) return @"iPad mini 2G (Cellular)";
从这里采取: https://github.com/monospacecollective/UIDevice-Hardware/blob/master/UIDevice-Hardware.m