How to determine the DPI of an iOs device?

I’m writing a business app in which the screen is mostly covered by a list view with a row of buttons at the bottom. Until now I’ve just done it quick’n’dirty and made the size of these buttons as a certain factor of the display pixel width.

The problem of couse is that while this look good on a high DPI phone it will look big and awful on a tablet with a similar resolution.

So lately I’ve started working in physical units (mm) (with certain limitations of course) when creating the buttons. This works well with Android devices, but for iOs I’m at loss. Is there any reasonalbly easy way to determine this?

Well with iOS devices, there are only a handful of models to choose from. I’m not sure if there is an actual dpi value available, but you could just hardcode some values based on the model name.

I think that if you find the “model” or "architecture"properties here, it will give you the device type. So you’ll know if it’s an iPad or a iPhone/iPod.

With the iPad you really only have 2 resolutions to worry about:

1536*2048

768*1024

Only the iPad1 and 2 use the lower res - and I don’t think the iPad 1 can support new corona builds since it was capped at using iOS5 so it’s really only the iPad 2 that will use the lower res. 

For the phone/ipod sizes you have:

320*480 - iPhone 3GS

640*960 - iPhone 4/4s

640*1136 - iPhone 5/5s

750*1334 - iPhone 6

1242*2208 - iPhone 6+

(I think they’re all correct, but you might want to look them up)

So in total there are only 7 resolutions to account for on iOS - less if you have some settings that would make them unavailable for iPad2 or 3GS.

Thanks for the tip! I have been on the getInfo() page myself, but I found the iOS device list to be very short and lacking most of the newer models. Is there a complete list somewhere? Or am I looking in the wrong direction?

So, what you suggest is to use system.getInfo(“architectureInfo”) to get strings like “iPhone2,1”. Then check for all models and by using the resolution numbers you wrote and googling for the physical screen sizes, determine the DPI number?

On a side note:

I wonder why Corona make something similar to the “androidDisplayApproximateDpi” for iOS. To me it seems a BIT more logical that Corona does this (the job described above) once per new released iOS device than 10000 developers individually. But that’s just me…  :stuck_out_tongue:

I suspect that it’s a property that Android itself has available, but iOS does not.  

Probably not too hard for someone at Corona to rig the function to return the 7 values for iOS devices, but also probably not at the top of their todo list either.

Well with iOS devices, there are only a handful of models to choose from. I’m not sure if there is an actual dpi value available, but you could just hardcode some values based on the model name.

I think that if you find the “model” or "architecture"properties here, it will give you the device type. So you’ll know if it’s an iPad or a iPhone/iPod.

With the iPad you really only have 2 resolutions to worry about:

1536*2048

768*1024

Only the iPad1 and 2 use the lower res - and I don’t think the iPad 1 can support new corona builds since it was capped at using iOS5 so it’s really only the iPad 2 that will use the lower res. 

For the phone/ipod sizes you have:

320*480 - iPhone 3GS

640*960 - iPhone 4/4s

640*1136 - iPhone 5/5s

750*1334 - iPhone 6

1242*2208 - iPhone 6+

(I think they’re all correct, but you might want to look them up)

So in total there are only 7 resolutions to account for on iOS - less if you have some settings that would make them unavailable for iPad2 or 3GS.

Thanks for the tip! I have been on the getInfo() page myself, but I found the iOS device list to be very short and lacking most of the newer models. Is there a complete list somewhere? Or am I looking in the wrong direction?

So, what you suggest is to use system.getInfo(“architectureInfo”) to get strings like “iPhone2,1”. Then check for all models and by using the resolution numbers you wrote and googling for the physical screen sizes, determine the DPI number?

On a side note:

I wonder why Corona make something similar to the “androidDisplayApproximateDpi” for iOS. To me it seems a BIT more logical that Corona does this (the job described above) once per new released iOS device than 10000 developers individually. But that’s just me…  :stuck_out_tongue:

I suspect that it’s a property that Android itself has available, but iOS does not.  

Probably not too hard for someone at Corona to rig the function to return the 7 values for iOS devices, but also probably not at the top of their todo list either.