1
votes

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

1
Apple's UIScreen documentation mentions "the value of this property may change when the device rotates." In landscape orientation, you'd want to use width to detect a 4" display, not height; revising your macro to use the right property based on orientation may be all you need.Calrion
thank you it works with width i don't really understand why it change between the 2 versions of xcode with the same settings but thanks it solve my problemAaleks

1 Answers

0
votes

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.