[iOS] How to programmatically check if running on an iPhone or iPad device

In Swift:

if UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiom.Pad {

In Objective-C:

if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)


To check if you are running on an iPhone:

In Swift:

if UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiom.Phone {

In Objective-C:

if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *