Determine device (iPhone, iPod Touch) with iOS

后端 未结 30 1754
礼貌的吻别
礼貌的吻别 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 11:51

    Below mentioned code snippet should help :

     if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
       // iPhone device
     }
     else if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
       // iPad device
     }
     else {
      // Other device i.e. iPod
     }
    

提交回复
热议问题