1

I'm trying to make an app that displays something in real-world units. It's not a ruler app, but it wants that kind of precision.

It already looks like the iPhone and iPod touch have different screen resolutions (160 & 163 respectively)

I've found this Calculating pixel size on an iPhone and this iPhone screen resolution changes in future hardware and this http://forums.macrumors.com/showthread.php?t=350612

From my reading it sounds like I can treat the 320 * 480 screen space as 2 * 3.5 inches, ignoring the difference between the iPod and the iPhone resolution, which only seems to affect the clarity of the image, not the size.

My question(s) are: is this true? any way to determine this (320 "pixels" == 2 inches) in code, so if it changes I don't have to update.

Community
  • 1
  • 1
Kenny Winker
  • 11,919
  • 7
  • 56
  • 78
  • You could provide an option within the app to recalibrate the scaling. – jon hanson Dec 02 '09 at 23:48
  • 1
    Good idea, but it sounds like a schlepp for the user. Hands up if you have a ruler handy. Two hands up if you have a ruler handy, and feel like calibrating some app on your phone. – Kenny Winker Dec 03 '09 at 00:02

3 Answers3

4

I wouldn't worry about it for now, if Apple changed it and didn't tell their developers then they would lose customers themselves. Just hard code your app to work in this environment for now.

The PPI shouldn't be different, but all other apps run fine and the only hardware differences Apple tells us to account for are microphone, camera, Internet connection, and phone-ness. (Even if the PPI is different, it's still 320X480 pixels no matter how many inches are used.)

fearmint
  • 5,276
  • 2
  • 33
  • 45
  • 2
    +1 for pragmatic answer, though I expect different resolutions will be forthcoming -- and you can solve it then. – DarkSquid Dec 02 '09 at 23:37
  • fair enough. If there was a way, I would implement it, but it doesn't seem like there is a way. I'm still not sure if I have to account for the 163/160 ppi issue. Any thoughts? – Kenny Winker Dec 02 '09 at 23:44
1

Reference the question which claims:

320 * 480 screen space as 2 * 3.5 inches

That claim is wrong. The screen size is a 2:3 ratio. The diagonal is 3.5 inches.

Using a 3.5 inch diagonal and using the 2:3 ratio, a calculation gives approximate screen dimensions of 1.94 * 2.91 inches.

It really is 320 * 480. It just is not 2 inches by 3.5 inches, nor even 2 inches by 3 inches. The display is a just a bit smaller than 2 inches by 3 inches. That is why it can be 320 * 480 and not be 160 ppi. (Or be 640 x 960 and not be 320 ppi with the iPhone 4).

Refactor
  • 524
  • 1
  • 11
  • 20
0

If you look how you calculate ppi, you need to know the advertised screen size in inches. I believe you are safe to deal with [[UIScreen mainScreen] bounds] as JoePasq said. You can set a const of what you think an inch is for yourself and use the width and height of the bounds to represent your measurement. This will allow you app to scale if they ever do change the size of the screen.

Scott Densmore
  • 1,459
  • 10
  • 10