iPhone development: what will [[UIDevice currentDevice] model] return for “iPad”? [closed]

ε祈祈猫儿з 提交于 2019-12-09 13:54:15

问题


What will [[UIDevice currentDevice] model] return for "iPad"?


回答1:


You can use UI_USER_INTERFACE_IDIOM(), which will either return UIUserInterfaceIdiomPhone or UIUserInterfaceIdiomPad. Bear in mind that on any device < 3.2, this is unavailable, so first check to see whether the property can be retrieved - in this case, it is not an iPad.

Or, alternatively, to specifically work out whether the platform is an iPad or not, use

if ([[[UIDevice currentDevice] model] containsString:@"iPad"]) {
    // Your code goes here
}

Hope this helps ;)




回答2:


I tried using containsString but it was not allowed with xcode4

Here is how I solved it:

if ([[[UIDevice currentDevice] model] hasPrefix:@"iPhone"])
    {

Hope this helps even if its a bit late.




回答3:


You might try the Apple Developer Forums.




回答4:


Well trying on simulator:

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

it gives iPad Simulator, will update the answer when I will get the device ;)



来源:https://stackoverflow.com/questions/2522418/iphone-development-what-will-uidevice-currentdevice-model-return-for-ipad

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