Search code examples
iosobjective-ciphonemacrosscreen-size

recognizing issues with iphone 5-5s in iOS8 (Xcode6)


In ios7, with Xcode5 i use a macro to detect if the device is iphone 5 or 4 ,4s. And i never had any problems it always work right.

#define IS_WIDESCREEN ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )568 ) < DBL_EPSILON )

        if (IS_WIDESCREEN){
            //5s
        }else{
            //4,4s            
        }

But in xcode6 it doesn’t work the IS_WIDESCREEN state is always false .

The problem is that in Xcode6 with iOS 8

[[ UIScreen mainScreen ] bounds ].size.height

is equal to 320 instead of 568.

Do i need to find a new macro ? I found on internet (iOS Writing Macro detect 3.5 inch or 4 inch display) the same is used to detect the iphone 5 screen size


Solution

  • Seems to be an iOS 8 feature, not Xcode. Try checking to see if the width is 568 as well as the height in case the device is in landscape. The change seems to be that the system gets the height in the current orientation, so to some degree the height property of UIScreen bounds is not constant.

    Hopes this helps someone.