I've just upgraded to XCode 4.5 GM and found out that you can now apply the '4" Retina' size to your view controller in the storyboard.
Now if I want to create an application that runs on both iPhone 4 and 5, of course I have to build every window twice, but I also have to detect whether the user has an iPhone with 3.5" or 4" screen and then apply the view.
How should I do that?
If the project is created using Xcode 6, then use the below mentioned code to detect the devices..
If the project was created in Xcode 5 and opened in Xcode 6, then use the below mentioned code to detect the devices.(This code works if no launching images for iPhone 6,6+ are assigned)
If you are still using Xcode 5 all together then use the following code to detect the devices (iPhone 6 and 6+ will not be detected)
Used to detect iPhone and iPad Devices of all versons.
Borrowing from Samrat Mazumdar's answer, here's a short method that estimates the device screen size. It works with the latest devices, but may fail on future ones (as all methods of guessing might). It will also get confused if the device is being mirrored (returns the device's screen size, not the mirrored screen size)
In Swift 3 you can use my simple class KRDeviceType.
https://github.com/ulian-onua/KRDeviceType
It well documented and supports operators ==, >=, <=.
For example to detect if device has bounds of iPhone 6/6s/7, you can just use next comparison:
To detect if device has bounds of iPhone 5/5S/SE or earlier (iPhone 4s) you can use next comparison:
We now need to account for iPhone 6 and 6Plus screen sizes. Here's an updated answer
Some useful info