How to detect user is using iPad or iPhone for iOS App at run time conditional coding purposes

At runtime, you want to detect whether the user is on an iPad or an iPhone for conditional coding purposes.

One requirement is to find the device’s screen size on an iPad, iPhone, or iPod touch.

Another way to do it is to write different code, i.e., conditional code per device, whether it be an iPad with a big screen or an iPhone with a smaller screen, or just to find out which storyboard you are writing code for.

The code is simple:

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
     // The device is an iPad running iOS 3.2 or later.
} else {
     // The device is an iPhone or iPod touch.

Hope it helps,

Thanks & Regards
Mandar Apte

Published by Mandar Apte

Mandar is a Mumbai-based multi-disciplinary designer with UX/UI, Logo, Symbol, and Brand Identity design expertise. He currently runs his Mudrkashar Linguistic Apple iPhone, iPad, and Mac app business in the heart of Mumbai city.

Leave a comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.