iPhone 4 resolution
Hey guys, here's a weird question. I'm doing device detection and I noticed that the iphone 4 reports the same resolution a开发者_运维知识库s the iphone 3g(s): 320x480.
shouldn't this be higher? or did I miss something?
Points Versus Pixels is a good read in this regard:
In iOS there is a distinction between the coordinates you specify in your drawing code and the pixels of the underlying device. When using native drawing technologies such as Quartz, UIKit, and Core Animation, you specify coordinate values using a logical coordinate space, which measures distances in points. This logical coordinate system is decoupled from the device coordinate space used by the system frameworks to manage the pixels on the screen. The system automatically maps points in the logical coordinate space to pixels in the device coordinate space, but this mapping is not always one-to-one. This behavior leads to an important fact that you should always remember:
One point does not necessarily correspond to one pixel on the screen.
You missed something. This is described in the WWDC "What's New Cocoa Touch" session (Session 101), if I recall correctly. (If you're a registered developer, you can download those on iTunes University.)
They kept the dimension reporting the same to ensure that apps scaled correctly in both iPhone 4 and iPhone 3/3G/3Gs. 1 point is no longer 1 pixel.
Essentially, the higher-resolution aspects that you'll use most will be new graphical assets. There is a naming convention, as well, which allows the phone to automatically determine whether to load a lower-resolution version of the resource (for 320x480 models), or the higher-resolution version (for 640x960 models).
Head over to the Apple Developer Site, sign in, and grab those videos. Great stuff came out of there.
(And boy, I hope I didn't just break NDA.)
Both retina and standard pixel displays use the same point system even with different screen resolutions. For example, this is why on iPhone - when asking the window.frame.size.. - returns 320X480, even when the iPhone has a retina display. iOS puts the image in place according to the point grid regardless of image resolution. That image resolution might as well be able to handle either standard or retina displays.
Therefore, always create images sized for retina pixel display.
Feel free to print out custom made graphing paper (with dimensions and commonly used components included) to help sketch out your views (not everything should be done digitally :D). http://achim.us/eli/iOS_Graph_Paper.pdf
NSLog(@"%f", [[UIScreen mainScreen] scale]);
Above statement would print 2 for iPhone 4S, iPhone-5 and 1 for iPhone 4 or previous models of iPhone.
精彩评论