2013-02-10 16 views

答えて

8

はい、間違いなく可能です。ライブカメラのフィードをUIViewに埋め込むことができます。UIViewは、好きな場所に置くことができます。ここで読み取ることで

スタート:AVFoundation Reference - あなたが探しているこれはあなたのフレームワークである

特定のクラスがAVCaptureSession

と連動していますそして、これがカバーサンプルプロジェクトでAVCaptureVideoPreviewLayer

です必要なもの:AVCam

3

私はあなたの最善の策はこれをつかんで理解することだと思います。apple sample code, called AVCam AVCaptureVideoPreviewLayerを作成する方法をコードに示します。これを、あなたの "バックグラウンド"として使用するUIViewのサブレイヤとして挿入します。

これを実行すると、そのUIViewはビュー階層の他の部分と同じようになります。あなたはバックグラウンドUIImageViewのように扱うことができます(しかし、バッターパワーをもっと消費するもの)。

7

インポート:

#import <AVFoundation/AVFoundation.h> 

viewDidLoadにこのコードを追加し、コントローラのビューにカメラビューを追加するには:

AVCaptureSession *session = [[AVCaptureSession alloc] init]; 
session.sessionPreset = AVCaptureSessionPresetHigh; 

AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; 

NSError *error = nil; 
AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device error:&error]; 
[session addInput:input]; 

AVCaptureVideoPreviewLayer *newCaptureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session]; 
newCaptureVideoPreviewLayer.frame = self.view.bounds; 

[self.view.layer addSublayer:newCaptureVideoPreviewLayer]; 

[session startRunning]; 
関連する問題