【发布时间】:2011-08-10 19:59:04
【问题描述】:
我正在尝试禁用任何可识别的方向旋转到 AVCaptureVideoPreviewLayer,同时仍保持任何子视图的旋转。 AVCaptureVideoPreviewLayer 确实有一个方向属性,并且更改它确实允许图层正确显示任何方向。但是,旋转涉及 AVCaptureVideoPreviewLayer 的一些时髦旋转,而不是像在 Camera 应用中那样保持平滑。
这就是我如何让方向正常工作,减去旋转中的障碍:
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
_captureVideoPreviewLayer.frame = self.view.bounds;
_captureVideoPreviewLayer.orientation = [[UIDevice currentDevice] orientation];
}
如何让这个层像相机应用一样工作,同时保持其子视图的旋转?
另外,顺便说一句,我已经看到 AVCaptureVideoPreviewLayer 上的方向属性已被贬值,应该使用 AVCaptureConnection 的 videoOrientation 属性,但我认为我没有 AVCaptureConnection 可以访问这里(我是只需在屏幕上显示相机)。我应该如何设置它以访问 videoOrientation?
【问题讨论】:
标签: iphone ios avfoundation