开发者

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

This question already has answers here: Closed 11 year开发者_开发问答s ago.

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


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
}


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.
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜