determine ipad device

前端 未结 5 1479
情歌与酒
情歌与酒 2020-12-09 00:18

I am writing a universal app for both iphone and ipad. How do I determine if the device is an iPad. I have used this link to determine the iPhone type (3G, 3GS).

Det

5条回答
  •  不思量自难忘°
    2020-12-09 00:57

    Brad's solution is absolutely right. If you're building a universal app designed to run on iPhones with older OS along with up-to-date iPads and iPhones, you might want to add this code to catch situations where the idiom is not defined.

    // If iPhoneOS is 3.2 or greater then __IPHONE_3_2 will be defined
    #ifndef __IPHONE_3_2    
    
    typedef enum {
        UIUserInterfaceIdiomPhone,           // iPhone and iPod touch
        UIUserInterfaceIdiomPad,             // iPad
    } UIUserInterfaceIdiom;
    
    #define UI_USER_INTERFACE_IDIOM() UIUserInterfaceIdiomPhone
    
    #endif // ifndef __IPHONE_3_2
    

提交回复
热议问题