iPhone开发:[[UIDevice currentDevice]型号]会为“iPad”返回什么? [英] iPhone development: what will [[UIDevice currentDevice] model] return for "iPad"?

查看:107
本文介绍了iPhone开发:[[UIDevice currentDevice]型号]会为“iPad”返回什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

[[UIDevice currentDevice]型号]将为iPad返回什么?

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

推荐答案

您可以使用 UI_USER_INTERFACE_IDIOM(),它将返回 UIUserInterfaceIdiomPhone UIUserInterfaceIdiomPad 。请记住,在任何设备上< 3.2,这是不可用的,所以首先检查是否可以检索属性 - 在这种情况下,它不是iPad。

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.

或者,或者,具体工作无论该平台是否是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
}

希望这个帮助;)

这篇关于iPhone开发:[[UIDevice currentDevice]型号]会为“iPad”返回什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆