iPad 2 检测 [英] iPad 2 detection

查看:22
本文介绍了iPad 2 检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因为我没有 iPad 2,所以我需要知道它在调用 [[UIDevice currentDevice] 模型] 时返回什么.我以为它只返回iPad",但似乎我错了.

Since I don't have iPad 2, I need to know what it returns when calling [[UIDevice currentDevice] model]. I thought it returns just "iPad" but it seems I'm wrong.

有人可以告诉我吗?

谢谢

推荐答案

检查带摄像头的 iPad.

Check for an iPad with a camera.

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

请注意,通常最好检测特定功能,而不是基于模型/版本检测做出全面假设.例如,如果你需要一个摄像头,那么明确地测试摄像头;如果您需要根据可用 RAM 量调整 UI 质量,请测试物理 RAM;等等.还要注意我写的评论,强调了使用的危险模型检测.

Note that it is generally better to detect specific features rather than make blanket assumptions based on model/version detection. For instance, if you need a camera, then test for the camera explicitly; if you need to tweak the UI quality based on the amount of RAM available, test for physical RAM; etc. Also note a comment I wrote that highlights the dangers of using model detection.

这篇关于iPad 2 检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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