Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect whether the host device is iPhone or iPad? [duplicate]

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

like image 564
Parth Bhatt Avatar asked Dec 03 '10 06:12

Parth Bhatt


2 Answers

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
}
like image 102
Satya Avatar answered Oct 15 '22 11:10

Satya


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.
}
like image 40
zhengyue Avatar answered Oct 15 '22 12:10

zhengyue