Is this possible? I want the number of inches, not the number of pixels. I know it is approximately 160 ppi. But not exactly.
There isn't an API that will give you this. Your best bet is to look at the device's screen size (in points) and from that surmise if it's an iPad or iPhone etc., and then use hard-coded values for the screen sizes.
Here's some code to get the screen size:
CGRect screenRect = [[UIScreen mainScreen] bounds]; CGFloat screenWidth = screenRect.size.width; CGFloat screenHeight = screenRect.size.height;
Be aware that width and height might be swapped, depending on device orientation.
If it were available it would be in UIScreen or UIDevice but it is not there.
You can infer it from info in Erica's UIDevice-extension and the specs for each device listed here on Wikipedia.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With