2

[[UIDevice currentDevice] model] 将为“iPad”返回什么?

4

4 回答 4

3

我尝试使用 containsString 但它不允许使用 xcode4

这是我解决它的方法:

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

希望这会有所帮助,即使它有点晚了。

于 2011-06-16T05:52:42.967 回答
2

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

或者,或者,要专门确定平台是否是 iPad,请使用

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

希望这可以帮助 ;)

于 2010-04-12T16:34:23.313 回答
1

你可以试试Apple Developer Forums

于 2010-03-26T10:29:54.180 回答
1

很好地尝试模拟器:

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

它提供了iPad 模拟器,当我拿到设备时会更新答案;)

于 2010-03-29T06:26:31.097 回答