Detect iOS device type

前端 未结 5 2020
感动是毒
感动是毒 2020-11-29 04:16

In my application (written in Objective-C), how do I detect if the device is an iPhone, iPad, or iPhone5?

if([[UIDevice currentDevice]userInterfaceIdiom] ==          


        
5条回答
  •  死守一世寂寞
    2020-11-29 05:03

    if ([[UIDevice currentDevice].model hasPrefix:@"iPhone"]) {//iPhone... (not iTouch or iPad)
    


    if ([[UIDevice currentDevice].model hasPrefix:@"iPad"]) {//iPad...
    


    if (([[UIDevice currentDevice].model hasPrefix:@"iPhone"]) && ([UIScreen mainScreen]bounds].size.height == 568)) {//iPhone5...
    



    And also, just for reference... iTouch is this:

    if ([[UIDevice currentDevice].model hasPrefix:@"iPod"]) {//iTouch
    

提交回复
热议问题