Is there an API for checking at runtime whether you are running on an iPhone or an iPad?
One way I can think of would be to use:
[[UIDevice currentDevice] model];
And detect the existence of the string @"iPad" - which seems a bit fragile.
In the 3.2 SDK, I see that UIDevice
also has a property which is really what I'm looking for, but doesn't work for pre-3.2 (obviously):
[[UIDevice currentDevice] userInterfaceIdiom];
Are there other ways than checking for the existence of @"iPad" for a universal app?
Checkout UI_USER_INTERFACE_IDIOM
.
Returns the interface idiom supported by the current device.
Return Value
UIUserInterfaceIdiomPhone
if the device is an iPhone or iPod touch orUIUserInterfaceIdiomPad
if the device is an iPad.The type of interface that should be used on the current device
typedef enum {
UIUserInterfaceIdiomPhone,
UIUserInterfaceIdiomPad,
} UIUserInterfaceIdiom;