I've looked a lot of post about iOS how to retrieve the real size. I found such solution but I think it doesn't work correctly for all devices.
+(float) getRealSize {
float scale = 1;
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) {
scale = [[UIScreen mainScreen] scale];
}
float dpi;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
dpi = 132 * scale;
} else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
dpi = 163 * scale;
} else {
dpi = 160 * scale;
}
CGRect originalFrame = [[UIScreen mainScreen] bounds];
float w = originalFrame.size.width;
float h = originalFrame.size.height;
return dpi * sqrtf(w*w + h*h);
}
How to update such method to support all devices? I want DPI (PPI) or inches. Or, may be, is there any library to help.
To prevent closing as dublicated: there is no proper solutions in stackoverflow. For, instance, iOS get physical screen size programmatically? Getting the physical screen size in inches for iPhone How to get the screen width and height in iOS? etc.,etc.,etc... no solution now.