iPhone 5 – How to detect the 4-inch Retina display?

As a start for our Developer Tips category, we will highlight today a surprising problem from Apple which has occured with the release of the iPhone 5.

The Issue

Until now, pictures used for the Retina display were automatically detected by checking if a file suffixed by @2x was present in the app (ie Default.png and Default@2x.png). That’s why the all new iPad mini can handle without modification the native iPad apps by using the low resolution images, because its screen resolution is the same as the first and second iPads.

The iPhone 5 is on its side capable of running iPhone Retina apps without problems thanks to the adjonction of the @2x suffix, but its case is more complex than the iPad mini. Indeed, it brings a new width/depth ratio unusual for the iOS devices. This prevents the iOS SDK to automatically detect the most suitable pictures for the iPhone 5.

A first step has been done in this direction by constraining the developers to provide a launch image called Default-568h@2x.png. 568h because it is the half-height of the iPhone 5’s screen which handles 1136 pixels. Logical!

But why not having provided a similar detection system pour other pictures in the app? Apple developers should have their reasons, but it does not ease our own developer lives if we want to fully support the iPhone 5 and continue to support the older generations. We, here at Xhaleera, have been concerned by this problem when adpating Nihongo no Kana.

Our Solution

The only solution we found is to select the pictures at runtime, by using the following code to detect the presence of the Retina 4-inch display.

We have placed the bit of code in our AppDelegate and you only have to call it that way to execute specific iPhone 5 code:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *