如何在运行时单独识别 ipad 1 和 ipad 2

发布于 2024-12-20 04:25:55 字数 390 浏览 1 评论 0原文

可能的重复:
使用 iPhone SDK 确定设备(iPhone、iPod Touch)< br> iPad 2 检测

请指导我如何在真实设备上运行时检测 ipad 和 ipad 2.. 我由于性能问题,想要将不同的图像加载到两台手机上。

提前致谢

Possible Duplicate:
Determine device (iPhone, iPod Touch) with iPhone SDK
iPad 2 detection

Please guide me on how to detect ipad and ipad 2 at runtime on real device.. I want to load different images to both handsets due to performance issue.

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浪推晚风 2024-12-27 04:25:55

最简单、最短的方法是检查摄像头,如 iPad 2 检测 中所述:

BOOL isIPad2 = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad &&
            [UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]);

或者更简单:
BOOL isiPad2 = [[自身平台] isEqualToString:@"iPad2,1"];
请记住,该字符串也可以是 iPad2,2iPad2,3

Easiest and shortest way is to check for a camera, as said in iPad 2 detection :

BOOL isIPad2 = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad &&
            [UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]);

Or even simpler:
BOOL isiPad2 = [[self platform] isEqualToString:@"iPad2,1"];
Remember that the string can be iPad2,2 and iPad2,3 as well.

锦爱 2024-12-27 04:25:55
- (NSString *)machine {
    size_t size;
    sysctlbyname("hw.machine", NULL, &size, NULL, 0);
    char *machine = malloc(size);
    sysctlbyname("hw.machine", machine, &size, NULL, 0);
    NSString *platform = [NSString stringWithCString:machine encoding:NSUTF8StringEncoding];
    free(machine);
    return platform;
}
  • iPad 1:@“iPad1,1”
  • iPad 2:@“iPad2,1”
- (NSString *)machine {
    size_t size;
    sysctlbyname("hw.machine", NULL, &size, NULL, 0);
    char *machine = malloc(size);
    sysctlbyname("hw.machine", machine, &size, NULL, 0);
    NSString *platform = [NSString stringWithCString:machine encoding:NSUTF8StringEncoding];
    free(machine);
    return platform;
}
  • iPad 1 : @"iPad1,1"
  • iPad 2 : @"iPad2,1"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文