[英]How do i detect what device the user of my app is using
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. 嘿伙计我的问题是我想检测我的用户是否正在使用iPhone 4(对于它的相机闪光灯)或任何其他iDevice。我知道如何检测iOS的版本。 or how would i detect the device has camera flash capabilities .
或者我如何检测设备具有相机闪光功能。
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. 就相机闪光而言,您可以使用UIImagePickerController的
isFlashAvailableForCameraDevice:
方法。 (You'll probably want to call this after first verifying the existance of a camera via the isCameraDeviceAvailable:
method) or the isFlashModeSupported:
method within the AVCaptureDevice Class . (您可能希望在首次通过
isCameraDeviceAvailable:
方法验证摄像机的存在之后调用此isCameraDeviceAvailable:
)或AVCaptureDevice类中的isFlashModeSupported:
方法。
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. 您通常不希望依赖设备的类型来确定其功能 - 可能是在其他市场销售的某些iPhone 4没有闪存,或者某些尚未公布的设备。 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. 在这种情况下,您可以调用+ [UIImagePickerController isFlashAvailableForCameraDevice:]来确定特定摄像机是否有闪光灯。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.