diff --git a/UIDevice-Hardware.h b/UIDevice-Hardware.h index c57a870..ec0d445 100644 --- a/UIDevice-Hardware.h +++ b/UIDevice-Hardware.h @@ -13,6 +13,8 @@ typedef NS_ENUM(NSUInteger, UIDeviceFamily) { UIDeviceFamilyiPod, UIDeviceFamilyiPad, UIDeviceFamilyAppleTV, + UIDeviceFamilySimulatoriPad, + UIDeviceFamilySimulatoriPhone, UIDeviceFamilyUnknown, }; diff --git a/UIDevice-Hardware.m b/UIDevice-Hardware.m index 38d7d2e..8c5a5d9 100644 --- a/UIDevice-Hardware.m +++ b/UIDevice-Hardware.m @@ -62,7 +62,7 @@ - (NSString *)modelNameForModelIdentifier:(NSString *)modelIdentifier if ([modelIdentifier isEqualToString:@"iPhone7,2"]) return @"iPhone 6"; if ([modelIdentifier isEqualToString:@"iPhone8,1"]) return @"iPhone 6s"; if ([modelIdentifier isEqualToString:@"iPhone8,2"]) return @"iPhone 6s Plus"; - + // iPad http://theiphonewiki.com/wiki/IPad if ([modelIdentifier isEqualToString:@"iPad1,1"]) return @"iPad 1G"; @@ -81,7 +81,7 @@ - (NSString *)modelNameForModelIdentifier:(NSString *)modelIdentifier if ([modelIdentifier isEqualToString:@"iPad4,2"]) return @"iPad Air (Cellular)"; if ([modelIdentifier isEqualToString:@"iPad5,3"]) return @"iPad Air 2 (Wi-Fi)"; if ([modelIdentifier isEqualToString:@"iPad5,4"]) return @"iPad Air 2 (Cellular)"; - + // iPad Mini http://theiphonewiki.com/wiki/IPad_mini if ([modelIdentifier isEqualToString:@"iPad2,5"]) return @"iPad mini 1G (Wi-Fi)"; @@ -106,15 +106,15 @@ - (NSString *)modelNameForModelIdentifier:(NSString *)modelIdentifier if ([modelIdentifier isEqualToString:@"iPod4,1"]) return @"iPod touch 4G"; if ([modelIdentifier isEqualToString:@"iPod5,1"]) return @"iPod touch 5G"; if ([modelIdentifier isEqualToString:@"iPod7,1"]) return @"iPod touch 6G"; // as 6,1 was never released 7,1 is actually 6th generation - + // Apple TV https://www.theiphonewiki.com/wiki/Apple_TV - + if ([modelIdentifier isEqualToString:@"AppleTV1,1"]) return @"Apple TV 1G"; if ([modelIdentifier isEqualToString:@"AppleTV2,1"]) return @"Apple TV 2G"; if ([modelIdentifier isEqualToString:@"AppleTV3,1"]) return @"Apple TV 3G"; if ([modelIdentifier isEqualToString:@"AppleTV3,2"]) return @"Apple TV 3G"; // small, incremental update over 3,1 if ([modelIdentifier isEqualToString:@"AppleTV5,3"]) return @"Apple TV 4G"; // as 4,1 was never released, 5,1 is actually 4th generation - + // Simulator if ([modelIdentifier hasSuffix:@"86"] || [modelIdentifier isEqual:@"x86_64"]) { @@ -132,6 +132,11 @@ - (UIDeviceFamily) deviceFamily if ([modelIdentifier hasPrefix:@"iPod"]) return UIDeviceFamilyiPod; if ([modelIdentifier hasPrefix:@"iPad"]) return UIDeviceFamilyiPad; if ([modelIdentifier hasPrefix:@"AppleTV"]) return UIDeviceFamilyAppleTV; + if ([modelIdentifier hasSuffix:@"86"] || [modelIdentifier isEqual:@"x86_64"]) + { + BOOL smallerScreen = ([[UIScreen mainScreen] bounds].size.width < 768.0); + return (smallerScreen ? UIDeviceFamilySimulatoriPhone : UIDeviceFamilySimulatoriPad); + } return UIDeviceFamilyUnknown; }