if (device == iPad), if (device == iPhone)
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){ // The device is an iPad running iOS 3.2 or later.}else{ // The device is an iPhone or iPod touch.}
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
and
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
The macros UI_USER_INTERFACE_IDIOM() also works on older iOS versions like iOS 3.0 without crashing.
UI_USER_INTERFACE_IDIOM()
is the best solution in your case since your app is universal. But if you are running an iPhone app on iPad than UI_USER_INTERFACE_IDIOM()
will return UIUserInterfaceIdiomPhone
, regardless of the device. For such purposes as that, you can use the UIDevice.model
property:
if ([[UIDevice currentDevice].model rangeOfString:@"iPad"].location != NSNotFound) { //Device is iPad}