Search code examples
iphonecocoa-touchios4device

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


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


Solution

  • 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
    }