Determine device (iPhone, iPod Touch) with iOS

后端 未结 30 2139
礼貌的吻别
礼貌的吻别 2020-11-21 11:29

Is there a way to determine the device running an application. I want to distinguish between iPhone and iPod Touch, if possible.

30条回答
  •  春和景丽
    2020-11-21 12:04

    For simple comparison I always like macro:

    #define IS_IPOD [[UIDevice currentDevice].model containsString:@"iPod"]
    #define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    #define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
    

    It's simple and easy to use.

提交回复
热议问题