0

AVCaptureSession私は好きなように設定しました:

AVCaptureSession *newSession = [[AVCaptureSession alloc] init];
AVCaptureDevice *camera = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];

NSError *error = nil;

AVCaptureDeviceInput *newInput = [[AVCaptureDeviceInput alloc] initWithDevice:camera error:&error];


if(error) {
    NSLog([error localizedDescription]);

}

AVCaptureMovieFileOutput *newOutput = [[AVCaptureMovieFileOutput alloc] init];


if([newSession canAddInput:newInput])
    [newSession addInput:newInput];
if ([newSession canAddOutput:newOutput])
    [newSession addOutput:newOutput];

[self setSession:newSession];
[self setInput:newInput];
[self setOutput:newOutput];

次に、ビューにプレビュー レイヤーを追加しました。

AVCaptureVideoPreviewLayer *layer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:[recorder session]];

[layer setBounds:[recordingView bounds]];
[layer setVideoGravity:AVLayerVideoGravityResizeAspectFill];

[[recordingView layer] insertSublayer:layer above:[recordingView layer]];

しかし、私はプレビューを取得しません。

私は iPod Touch 第 4 世代で IOS 5 を使用しています。

ありがとう。

4

1 に答える 1

2

まず、あなたはどのようにrecordingView定義されていますか?2番、

[[recordingView layer] insertSublayer:layer above:[recordingView layer]];

意味がありません。(自分のレイヤー内の自分のレイヤーの上にレイヤーを追加しようとしています ->duh?)[recordingView.layer addSublayer:layer];代わりに試してください。

コメントに投稿されたプロジェクトでは、弱いポインタのゼロ化が使用されています。代わりにプロパティを強力にマークすると、すべてが機能します。

于 2011-10-26T12:10:20.390 に答える