Can I use the following code to detect if my app is running on iPad? My app needs to run on iOS 3.0 or higher.
if([[[UIDevice currentDevice] model] isEqualToString:@"iPad"]){
//Do iPad stuff.
}
To find your device, sign in to iCloud.com/find. Or use the Find My app on another Apple device that you own. If your iPhone, iPad, or iPod touch doesn't appear in the list of devices, Find My was not turned on. But you can still protect your account if Find My was not turned on.
To check if it is really not a fake Apple Device you can do the following: selfsolve.apple.com - input the serial number here it will show you some information about the device THE MODEL sometimes Year Released!
Use the UI_USER_INTERFACE_IDIOM()
macro on iOS >= 3.2:
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
//device is an iPad.
}
On earlier versions of iOS, you can fall back to your code, namely this:
NSRange ipadRange = [[[UIDevice currentDevice] model] rangeOfString:@"iPad"];
if(ipadRange.location != NSNotFound) {
//Do iPad stuff.
}
This approach is forward-compatible in the sense that if next year Apple released a different iPad, the model name might change, but the word "iPad" will definitely be somewhere inside the string.
Nope. Do this instead:
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
// ...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With