6

Possible Duplicate:
Best way to programmatically detect iPad/iPhone hardware

I am preparing an app where in I want to use it on iPhone as well as iPad.

How to detect whether the current host device is iPhone or iPad?

Based on this I want to make changes to the User Interface

Community
  • 1
  • 1
Parth Bhatt
  • 19,381
  • 28
  • 133
  • 216
  • http://stackoverflow.com/questions/12479344/checking-if-users-device-is-ipad-or-iphone-ipod-difference-between-two-ways/23518735#23518735 – Waseem Shah May 07 '14 at 13:16

2 Answers2

11

There are so many ways to find in which device the App is running.

[[[UIDevice currentDevice] systemVersion] floatValue];

by using this code we can get current device version, so that we can check whether the device is iPhone of iPad.

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
    // iPad-specific interface here
}
else
{
    // iPhone and iPod touch interface here
}
halfer
  • 19,824
  • 17
  • 99
  • 186
Satya
  • 3,320
  • 1
  • 20
  • 19
2

This is the 'official' way to detect the device type at runtime:

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
   // The device is an iPad running iPhone 3.2 or later.
}
else
{
  // The device is an iPhone or iPod touch.
}
zhengyue
  • 1,268
  • 12
  • 18