AVCaptureVideoPreviewLayer

AVCaptureVideoPreviewLayer

看起来avcapturevideopreviewlayer的方向已在iOS 6中贬值。有人知道新代码吗?这是我当前的(折旧的)代码:

[self setPreviewLayer:[[AVCaptureVideoPreviewLayer alloc] initWithSession:[self captureSession]]];
[[self previewLayer] setVideoGravity:AVLayerVideoGravityResizeAspectFill];
previewLayer.orientation = UIInterfaceOrientationLandscapeRight;

最佳答案

您检查文档了吗?只有一行:


  图层的方向。 (在iOS 6.0中已弃用。使用videoOrientation
  (AVCaptureConnection)。)


因此使用:

[[AVCaptureVideoPreviewLayer connection] setVideoOrientation: AVCaptureVideoOrientationLandscapeRight];


要么

AVCaptureVideoPreviewLayer.connection.videoOrientation= AVCaptureVideoOrientationLandscapeRight;

08-17 14:53