How to detect dpi on ipad mini?

I have an ipad app with pretty small touch dots that are hardly acceptable on a 10 inch screen of a regular ipad. I would like to be able to get dpi for the device so that I can scale the size of the small elements for the mini and any future mini that were released.

+6
source share
2 answers

DPI - 163 pixels per inch (ppi):

http://www.apple.com/ipad-mini/specs/

You cannot get this programmatically, so you will need to store it as a constant in your code.

+4
source

You cannot get the dpi value (or more correctly ppi) directly, because you need to know the number of millimeters (or inches) of the physical screen.
First you need to determine whether it is a mini-mini-iPad or not, and then you save the dpi value for each (still known) device in your application.

As the time of writing, this code detects iPad mini:

#include <sys/utsname.h> NSString *machineName() { struct utsname systemInfo; if (uname(&systemInfo) < 0) { return nil; } else { return [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding]; } } // detects iPad mini by machine id + (BOOL) isIpadMini { NSString *machName = machineName(); if (machName == nil) return NO; BOOL isMini = NO; if ( [machName isEqualToString:@"iPad2,5"] || [machName isEqualToString:@"iPad2,6"] || [machName isEqualToString:@"iPad2,7"]) { isMini = YES; } return isMini; } 

This is not the future, because a new machine identifier may be introduced later, but there is no future security method.
If it's iPad mini, use 163 dpi, otherwise use the links above in the comments to calculate dpi for iPhone and iPad.

+3
source

All Articles