-
-
Save avesus/306bc547faf68ae2cde2 to your computer and use it in GitHub Desktop.
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
float screenResolution() { | |
struct utsname systemInfo; | |
uname(&systemInfo); | |
char *name = systemInfo.machine; | |
float ppi; | |
if ((strstr(name, "iPod") != NULL) && (strstr(name, "iPod4") == NULL)) { | |
// older ipod touches | |
ppi = 163; | |
} else if ((strstr(name, "iPhone") != NULL) && (strstr(name, "iPhone3") == NULL)) { | |
// older non-retina iphones | |
ppi = 163; | |
} else if ((strstr(name, "iPad") != NULL) && (strstr(name, "iPad3") == NULL)) { | |
// ipad 1, ipad 2 | |
ppi = 132; | |
} else if (strstr(name, "iPad3") != NULL) { | |
// ipad 3 | |
ppi = 264; | |
} else { | |
// iphone 4/4s, ipod touch 4g or simulator | |
ppi = 326; | |
} | |
return ppi; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment