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?
I've taken the liberty to put the macro by Macmade into a C function, and name it properly because it detects widescreen availability and NOT necessarily the iPhone 5.
The macro also doesn't detect running on an iPhone 5 in case where the project doesn't include the Default-568h@2x.png. Without the new Default image, the iPhone 5 will report a regular 480x320 screen size (in points). So the check isn't just for widescreen availability but for widescreen mode being enabled as well.
I used hfossli's answer and translated it to Swift
I think it should be good if this macro will work in device and simulator, below are the solution.
Here is our codes, test passed on ios7/ios8 for iphone4,iphone5,ipad,iphone6,iphone6p, no matter on devices or simulator:
Add a 'New Swift File'->
AppDelegateEx.swift
add an extension to
AppDelegate
usage:
Here is the correct test of the device, without depending on the orientation