Does UI_USER_INTERFACE_IDIOM work with Targeted Device Family

匆匆过客 提交于 2019-12-06 12:11:44

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.)

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)

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;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!