iPad:示例项目AVCapture:将视频预览旋转为不同的方向?

| iPad:示例项目AVCapture:如何旋转不同方向的视频预览?     
已邀请:
如果您想采用简单的方法,只需不支持UIInterfaceOrientation以外的任何方向,即可正确显示图像。 否则,您将必须在layer0ѭ方法中将转换应用于与界面方向相反的预览层。例如,UIInterfaceOrientationLandscapeLeft是(IIRC)顺时针旋转90°。因此,请对预览层逆时针旋转90°进行补偿。     
这是我用的:
- (void)willAnimateRotationToInterfaceOrientation: (UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    [CATransaction begin];
    self.prevLayer.orientation = toInterfaceOrientation; //AVCaptureVideoPreviewLayer
    self.prevLayer.frame = self.view.frame;
    [CATransaction commit];

    [super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
}
    

要回复问题请先登录注册