问题描述
我一直试图弄清楚如何在 iPhone 的 UIView
中嵌入一个小的(ish)实时摄像头视图,但无济于事.
我什至无法在网上找到任何样本.我知道这是可行的,但我什至不知道从哪里开始.似乎有很多例子,其他人在相机的完整屏幕视图中添加了视图,但反过来却没有......
I've been trying to figure out how to embed a small(ish) live camera view inside of an iPhone's UIView
to no avail.
I have not even been able to find any samples of that on the net either. I know that it's do-able, but I don't even know where to start. There seem to be a lot of examples where others have added views TO the full-blown screen view of the camera, but not the other way around...
似乎UIImagePickerControllerSourceTypeCamera
只是显示了BIG modal camera观众,拍照者,所以(我认为)不适合我的目的.
It seems that UIImagePickerControllerSourceTypeCamera
just displays the BIG modal cameraviewer, picture taker, so it is unsuitable (I think) for my purposes.
我想在 UIView
内有一个小的实时相机视图,并且我可以添加我自己的按钮用于拍照(我可能会想出这个 - 某种类型的代表来捕捉图片)
I want to have a small live camera view, inside a UIView
, and I can add my own buttonsfor taking the pic (I can probably figure this out - a delegate of some sort to capturethe image)
谢谢...
推荐答案
为了您的目的,您需要使用 AVFoundation,具体查看 AVCaptureSession
, AVCaptureDeviceInput
,您可以使用它们来访问相机并查看 AVCaptureVideoPreviewLayer
这将允许您将相机输入绘制到屏幕上,您需要的一切都在那里..
For your purpose you need to use AVFoundation, specifically look at AVCaptureSession
, AVCaptureDeviceInput
, which you can use in order to get access to the cameras and look into AVCaptureVideoPreviewLayer
which will allow you to draw the camera input to the screen, everything you need is in there..
这篇关于在 UIView 中嵌入实时相机视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!