#if check (preprocessor macro) to differentiate between iPhone and iPad

后端 未结 5 1135
别那么骄傲
别那么骄傲 2021-02-04 12:13

Is there a build preprocessor macro I can check, with #if or #ifdef to determine if my current Xcode project is being built for iPhone or iPad?

5条回答
  •  太阳男子
    2021-02-04 13:00

    Some ideas in the comment section of this blog

    http://greensopinion.blogspot.com/2010/04/from-iphone-to-ipad-creating-universal.html

    Mostly using

    UI_USER_INTERFACE_IDIOM()
    

    Such as:

    #ifdef UI_USER_INTERFACE_IDIOM()
      #define IS_IPAD() (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    #else
      #define IS_IPAD() (false)
    #endif
    

提交回复
热议问题