iosobjective-cipadiphone-sdk-3.0iphone-sdk-3.2

iPhone development: what will [[UIDevice currentDevice] model] return for "iPad"?


What will [[UIDevice currentDevice] model] return for "iPad"?


Solution

  • You can use UI_USER_INTERFACE_IDIOM(), which will either return UIUserInterfaceIdiomPhone or UIUserInterfaceIdiomPad. Bear in mind that on any device < 3.2, this is unavailable, so first check to see whether the property can be retrieved - in this case, it is not an iPad.

    Or, alternatively, to specifically work out whether the platform is an iPad or not, use

    if ([[[UIDevice currentDevice] model] containsString:@"iPad"]) {
        // Your code goes here
    }
    

    Hope this helps ;)