Last active
December 28, 2015 09:49
-
-
Save sag333ar/7482150 to your computer and use it in GitHub Desktop.
Detect device type of iPhone
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define IS_HEIGHT_GTE_568 [[UIScreen mainScreen ] bounds].size.height >= 568.0f | |
typedef NS_ENUM(NSInteger, DeviceType) { | |
DeviceType_iPhone3Gs, | |
DeviceType_iPhone4_4s, | |
DeviceType_iPhone5, | |
}; | |
- (DeviceType)getTypeOfDevice { | |
if ([[UIScreen mainScreen] respondsToSelector:@selector(displayLinkWithTarget:selector:)] && | |
([UIScreen mainScreen].scale == 2.0)) { | |
return (IS_HEIGHT_GTE_568)?DeviceType_iPhone5:DeviceType_iPhone4_4s; | |
} else { | |
return DeviceType_iPhone3Gs; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment