测试 iPhone4 上的前置或后置摄像头

发布于 2024-09-26 13:18:02 字数 314 浏览 1 评论 0原文

我编写了一个应用程序,使用 UIImagePickerController 设置一些相机值(持续时间、质量等),并且工作正常。然而,在 iPhone 4 上,我从前置摄像头开始,如果用户切换到后置摄像头,质量设置就会丢失。有没有办法可以测试用户是否在前置摄像头和后置摄像头之间切换?

通过使用

if (imagePicker.cameraDevice=UIImagePickerControllerCameraDeviceFront) ,

它会告诉我相机是否设置为前置摄像头,但如果用户使用屏幕切换器切换相机,它不会返回相机值。

任何帮助将不胜感激。

I wrote an application that sets some camera values (duration, quality, etc) using UIImagePickerController and it works fine. However, on an iPhone 4, I start with the front camera and if the user switches to the rear camera, the quality settings are lost. Is there a way that I can test if the user switches between the front and rear camera?

By using

if (imagePicker.cameraDevice=UIImagePickerControllerCameraDeviceFront)

it will tell me if the camera is set to the front camera but if the user switches cameras using the screen switcher, it won't return the camera value.

Any help here would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

メ斷腸人バ 2024-10-03 13:18:02

您可能需要 AVCaptureDevice 通知:

  • AVCaptureDeviceWasDisconnectedNotification
  • AVCaptureDeviceWasConnectedNotification

观察它们并做出相应反应。

You probably need AVCaptureDevice notifications:

  • AVCaptureDeviceWasDisconnectedNotification
  • AVCaptureDeviceWasConnectedNotification

Observe them and react accordingly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文