如何以编程方式启动iPad的前置摄像头?
我想在应用程序启动时启动 iPad 的前置摄像头。
我如何以编程方式做到这一点?
请告诉我。
I would like to start front camera of the iPad when app starts.
How do I do it programmatically?
Please let me know.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要做的第一件事是检测您的设备是否有前置摄像头。为此,您需要遍历视频设备。
尝试
UIImagePickerController
的这个方法:这是一个类方法,
UIImagePickerControllerCameraDevice
可以采用两个值:示例代码:
请注意,这适用于 iOS 4.0 及更高版本。
另外我不确定是否有任何 API 可以预先启动前置摄像头。相机似乎总是以用户上次使用时的相同模式启动。也许苹果故意没有公开任何 API 来改变这一点。也许苹果希望用户对此做出呼吁。
尽管如此,您至少可以检测到 Fron Camera & 功能的可用性。提供您的功能。
First thing you need to do is to detect if your device has got front-facing camera. For that you need to iterate through the video devices.
Try this method of
UIImagePickerController
:This is a class method and
UIImagePickerControllerCameraDevice
can take two values:Example code:
Note that this is available for iOS 4.0 and later.
Also I am not sure if there is any API's to start the front-facing camera up front. The camera always seems to start in the same mode that the user left it the last time it was used. Maybe by design Apple did not expose any API's to change this. Maybe Apple wanted the users to make a call on this.
Nevertheless you can atleast detect the availability of Fron Camera & provide your feature.
如果我正确理解你的问题,你所要做的就是将相机打开为前置模式而不是后置模式,因此在第一次调用选择器的方法中写入以下内容:
picker.cameraDevice=UIImagePickerControllerCameraDeviceFront;
希望这能回答您的问题。
If I understand your question correctly, all you have to do is open your Camera to be in Front Mode instead of Rear Mode, so write this inside the method where you call the picker for the first time:
picker.cameraDevice=UIImagePickerControllerCameraDeviceFront;
Hope this answers your question.