10

根据http://developer.apple.com/iphone/library/qa/qa2010/qa1702.html ,我能够使用 AVCaptureSession 从相机捕获视频帧。但是,似乎 AVCaptureScreen 从相机捕获帧而不在屏幕上显示相机流。我还想像在 UIImagePicker 中一样显示相机流,以便用户知道相机正在打开并看到相机指向的内容。任何帮助或指针将不胜感激!

4

1 回答 1

19

AVCaptureVideoPreviewLayer正是您正在寻找的。

Apple 用来演示如何使用它的代码片段是:

AVCaptureSession *captureSession = <#Get a capture session#>;
AVCaptureVideoPreviewLayer *previewLayer = [AVCaptureVideoPreviewLayer layerWithSession:captureSession];
UIView *aView = <#The view in which to present the layer#>;
previewLayer.frame = aView.bounds; // Assume you want the preview layer to fill the view.
[aView.layer addSublayer:previewLayer];
于 2010-08-02T02:10:49.030 回答