iOS写入宏检测3.5英寸或4英寸显示器

iOS写入宏检测3.5英寸或4英寸显示器,ios,objective-c,macros,c-preprocessor,Ios,Objective C,Macros,C Preprocessor,我正在尝试编写一个宏来确定设备是3.5英寸还是4英寸。下面有一些类似的东西 #define IOS_OLDER_THAN_6 ( [ [ [ UIDevice currentDevice ] systemVersion ] floatValue ] < 6.0 ) #define IOS_NEWER_OR_EQUAL_TO_6 ( [ [ [ UIDevice currentDevice ] systemVersion ] floatValue ] >= 6.0 )

我正在尝试编写一个宏来确定设备是3.5英寸还是4英寸。下面有一些类似的东西

    #define IOS_OLDER_THAN_6 ( [ [ [ UIDevice currentDevice ] systemVersion ] floatValue ] < 6.0 )
    #define IOS_NEWER_OR_EQUAL_TO_6 ( [ [ [ UIDevice currentDevice ] systemVersion ] floatValue ] >= 6.0 )
#定义早于_6的IOS([[[UIDevice currentDevice]systemVersion]floatValue]<6.0)
#将IOS_更新的_或等于_定义为_6([[[UIDevice currentDevice]systemVersion]floatValue]>=6.0)

有人能帮我吗。请

您可以使用以下方法检测iPhone 3.5英寸或4英寸:-

#define isiPhone5  ([[UIScreen mainScreen] bounds].size.height == 568)?TRUE:FALSE
您可以使用以下方法进行检查,例如:-

     if (isiPhone5)
     {
           // this is iphone 4 inch
     }
     else
     {

           //Iphone  3.5 inch
     }
请查看此链接,因为您了解有关确定设备为3.5英寸或4英寸的宏的所有信息。


意思是这样的:

#define IS_IPHONE5 (([[UIScreen mainScreen] bounds].size.height-568)?NO:YES)

您可以这样检查它是否是iphone 5(4英寸):

#define IS_IPHONE5 (([[UIScreen mainScreen] bounds].size.height-568)?NO:YES)
iPhone5的屏幕高度为568

if ([ [ UIScreen mainScreen ] bounds ].size.height == 568)

此宏不正确。代码:max=IS_iPhone5?5 : 6; 我收到1封信,因为你忘了加护腕。如果else格式在这里是不必要的。下面是正确的代码:#定义isiPhone5([[UIScreen mainScreen]bounds].size.height==568)在iOS8中没有绑定方向?@sjoerdPerforts您是对的。我在另一个问题的答案中添加了一个检查,因为这个问题的答案不再被接受:参见