iPad 2检测 [英] iPad 2 detection

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

问题描述

由于我没有iPad 2,因此在调用[[UIDevice currentDevice] model]时我需要知道它返回的内容。我认为它只返回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天全站免登陆