iOS 6中不推荐使用方向

Mar*_*man 5 iphone

看起来avcapturevideopreviewlayer的方向已在iOS 6中折旧.任何人都知道新代码?这是我目前的(折旧)代码:

[self setPreviewLayer:[[AVCaptureVideoPreviewLayer alloc] initWithSession:[self captureSession]]];
[[self previewLayer] setVideoGravity:AVLayerVideoGravityResizeAspectFill];
previewLayer.orientation = UIInterfaceOrientationLandscapeRight;
Run Code Online (Sandbox Code Playgroud)

Nik*_*uhe 19

你查过文件了吗?它只有一行:

图层的方向.(在iOS 6.0中不推荐使用.请改用videoOrientation (AVCaptureConnection).)

所以使用:

[[AVCaptureVideoPreviewLayer connection] setVideoOrientation: AVCaptureVideoOrientationLandscapeRight];
Run Code Online (Sandbox Code Playgroud)

要么

AVCaptureVideoPreviewLayer.connection.videoOrientation= AVCaptureVideoOrientationLandscapeRight;
Run Code Online (Sandbox Code Playgroud)

  • 这不起作用 - 它与改变.orientation没有相同的效果. (2认同)