How to detect iPhone 5 (widescreen devices)?

前端 未结 24 1276
我寻月下人不归
我寻月下人不归 2020-11-22 00:50

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 a

24条回答
  •  抹茶落季
    2020-11-22 01:19

    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.

    BOOL isWidescreenEnabled()
    {
        return (BOOL)(fabs((double)[UIScreen mainScreen].bounds.size.height - 
                                                   (double)568) < DBL_EPSILON);
    }
    

提交回复
热议问题