Author Topic: How to programmatically check if running on an iPhone or iPad device  (Read 26630 times)

kjmcneish

  • Administrator
  • *****
  • Posts: 719
    • View Profile
To check if you are running on an iPad:

In Swift:

Code: [Select]
if UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiom.Pad {
In Objective-C:

Code: [Select]
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
To check if you are running on an iPhone:

In Swift:

Code: [Select]
if UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiom.Phone {
In Objective-C:

Code: [Select]
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
All the best!
Kevin McNeish
Author of Learn to Code in Swift: https://itunes.apple.com/us/book/learn-to-code-in-swift/id942956811?mt=11
Check out our Robot Tic-Tac-Toe app: https://itunes.apple.com/us/app/robot-tic-tac-toe/id990638517?mt=8
« Last Edit: November 15, 2015, 10:19:31 AM by kjmcneish »