简体   繁体   English

如何检测我的应用程序用户正在使用的设备

[英]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. 就相机闪光而言,您可以使用UIImagePickerControllerisFlashAvailableForCameraDevice:方法。 (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.

相关问题 如何检测运行我的功能测试的iOS设备? - How do I detect what iOS device my function tests are running on? 如何检测用户是在移动设备上并提供应用程序 - How To Detect User is on a mobile device and offer app 如何通过共享whatsapp中的应用程序链接来检测我的应用程序是否已安装在其他用户的设备中? - How to detect whether my app is installed in other user's device or not, via sharing the app link in whatsapp? 如何使用我的网站检查我的应用程序是否已安装在设备上? - How do I check if my app is installed on the device using my web site? 如何检测用户是否购买了其他应用? - How do I detect if my other apps were bought by the user? 如何在 SwiftUI 应用程序中获取用户的设备高度? - How do I get the user’s device height in a SwiftUI App? 如何配置我的应用程序以检测震动事件? - How do I configure my app to detect shake motion events? 如何在 iOS 上检测设备的方向? - How Do I detect the orientation of the device on iOS? 如何检测用户是否为我的应用程序中的本地通知设置了横幅样式警报或“常规”样式警报? - How do I detect if user has set banner style alerts or 'normal' style alerts for local notifications in my app? 如何为特定的iOS设备编译我的应用程序? - How do I compile my app for a specific iOS device?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM