如何检测我的应用程序的用户正在使用什么设备
大家好,我的问题是我想检测我的用户是否使用 iPhone 4(用于其相机闪光灯)或任何其他 iDevice。我知道如何检测 iOS 版本。或者我如何检测设备是否具有相机闪光灯功能。
Hey guys my question is i want to detect if my user is using a iPhone 4 (For its camera flash) or any other iDevice .I know how to detect what version of iOS. or how would i detect the device has camera flash capabilities .
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最好只是检查您需要的特定功能,而不是尝试根据设备进行推测。 (否则未来的设备将要求您编辑代码。)
就相机闪光灯而言,您可以使用 UIImagePickerController 的
isFlashAvailableForCameraDevice:
方法。 (您可能需要在首先通过isCameraDeviceAvailable:
方法验证相机是否存在后调用此方法)或 AVCaptureDevice 类。It's best to simply check for the specific features you require, rather than attempt to speculate based on the device. (Otherwise future devices will require you to edit your code.)
In terms of the camera flash, you could for example use the the UIImagePickerController's
isFlashAvailableForCameraDevice:
method. (You'll probably want to call this after first verifying the existance of a camera via theisCameraDeviceAvailable:
method) or theisFlashModeSupported:
method within the AVCaptureDevice Class.您通常不想根据设备的类型来确定其功能 - 可能其他市场上销售的某些 iPhone 4 没有闪光灯,或者某些尚未发布的设备有闪光灯。查询您感兴趣的功能而不是特定的设备类型始终是一个更好的主意。
此时,您可以调用 +[UIImagePickerController isFlashAvailableForCameraDevice:] 来判断特定相机是否有闪光灯。
You generally don't want to depend on the type of the device to determine its features -- it might be that some iPhone 4's sold in other markets don't have a flash, or that some not-yet-announced device does. It's always a better idea to query for the features you're interested in rather than the particular device type.
In this case, you can call +[UIImagePickerController isFlashAvailableForCameraDevice:] to determine whether a specific camera has a flash.