How to detect iPhone 5 (widescreen devices)?

前端 未结 24 1761
我寻月下人不归
我寻月下人不归 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:00

    I think it should be good if this macro will work in device and simulator, below are the solution.

    #define IS_WIDESCREEN (fabs((double)[[UIScreen mainScreen]bounds].size.height - (double)568) < DBL_EPSILON)
    #define IS_IPHONE (([[[UIDevice currentDevice] model] isEqualToString:@"iPhone"]) || ([[[UIDevice currentDevice] model] isEqualToString: @"iPhone Simulator"]))
    #define IS_IPOD   ([[[UIDevice currentDevice]model] isEqualToString:@"iPod touch"])
    #define IS_IPHONE_5 ((IS_IPHONE || IS_IPOD) && IS_WIDESCREEN)
    

提交回复
热议问题