2

So I'm currently using UI_USER_INTERFACE_IDIOM in conjunction with [[UIDevice currentDevice] model] to check if I'm on an iPhone, iPod or iPad. What I've found is that in the iPad simulator 3.2, UI_USER_INTERFACE_IDIOM still evaluates to UIUserInterfaceIdiomPhone (iPhone).

I'm wondering if this has something to do with my Targeted Device Family setting. I'm only targeting iPhone for my App (I don't want to make a universal app with scaling views). However, I support the 3.2 SDK so I still want users that have an iPad to be able to run my iPhone app. Will UI_USER_INTERFACE_IDIOM evaluate correctly on the iPad even when I'm targeting iPhone?

unjust
  • 167
  • 1
  • 2
  • 8

3 Answers3

2

UI_USER_INTERFACE_IDIOM does not check if the device is an iPhone or iPad. What it checks is whether the user interface is in iPhone mode (the 1x/2x thing) or iPad mode.

If an app isn't configured to target iPad, it will always return UIUserInterfaceIdiomPhone because the UI is an iPhone app. It is a feature by design.

And even if the app is configured to target iPhone only, the iPad should be able to run it without any problems as long as you use the methods as documented.

(If you need iPad-specific capabilities, do not check whether the device really is an iPad. Instead, check for individual capability.)

kennytm
  • 510,854
  • 105
  • 1,084
  • 1,005
  • I'm trying to determine whether or not to link phone numbers to phone call actions based on the device's calling capability. There is a method or macro I could use to determine this? – unjust Jul 05 '10 at 22:20
  • @unjust: You can weakly link to CoreTelephony (I assume you're using CT), then check if some classes e.g. `CTCall` exists using NSClassFromString. – kennytm Jul 06 '10 at 06:08
  • Will [[UIDevice currentDevice] model] come up as iPad? I am trying to make sure that only the iPad can auto-rotate. – Felixs Sep 03 '10 at 18:52
0

Best I can offer is that on the iPad simulator (3.2) while running in "iPhone" mode the

NSLog(@"model : %@", [UIDevice currentDevice].model);

returns

model : iPhone Simulator

(as a note: I am building for "iPhone" only and thus running in the iPhone experience on iPad. I have to assume the "model" name returned is affected by that)

bladnman
  • 2,591
  • 1
  • 25
  • 20
0

As people have said, check the individual capability.

For making a call, do this

// Only show the button if its is a device capable of making calls
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"tel:"]]) {
    self.Button.hidden = NO;
} else {
    self.Button.hidden = YES;
}
Robert
  • 37,670
  • 37
  • 171
  • 213