【问题标题】:iPhone development: what will [[UIDevice currentDevice] model] return for "iPad"? [closed]iPhone 开发:[[UIDevice currentDevice] model] 将为“iPad”返回什么? [关闭]
【发布时间】:2011-02-01 02:52:20
【问题描述】:

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

【问题讨论】:

  • 这是在 NDA 下,所以在 NDA 解除之前,您的问题可能会被忽略。文档指出model 为这些相应的设备返回一个类似“iPod Touch”或“iPhone”的字符串,所以一个手杖做出有根据的猜测..
  • @Jasarien:如果我没记错sdk版本beta_5不在保密协议下,如果我错了请纠正我。
  • @Madhup,我相信它仍然是。在 iPhone 开发者网站上,警告仍然存在:“iPhone SDK 3.2 beta 5 是预发布软件,被视为 Apple 机密信息。”虽然它可用于提交 iPad 应用程序,但仍处于 NDA 之下。

标签: ios objective-c ipad iphone-sdk-3.0 iphone-sdk-3.2


【解决方案1】:

我尝试使用 containsString,但 xcode4 不允许这样做

我是这样解决的:

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

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

【讨论】:

    【解决方案2】:

    您可以使用UI_USER_INTERFACE_IDIOM(),它将返回UIUserInterfaceIdiomPhoneUIUserInterfaceIdiomPad。请记住,在任何

    或者,或者,要具体确定平台是否为 iPad,请使用

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

    希望这会有所帮助;)

    【讨论】:

      【解决方案3】:

      在模拟器上试一试:

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

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

      【讨论】:

      • @g.revolution :然后等待有人拿到设备并发布答案;)
      • 在 iPad 3G 上对此进行了测试,它只给了我“iPad”。也希望能读到 3G,但运气不好
      【解决方案4】:

      你可以试试Apple Developer Forums

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2023-03-10
        • 1970-01-01
        • 1970-01-01
        • 2012-09-02
        • 2011-01-28
        • 2011-06-03
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多