AVCaptureConnection videoOrientation肖像不起作用

时间:2019-09-18 11:07:52

标签: ios iphone orientation avcapturesession

我正在尝试从我的自定义相机视图控制器获取图像,并且捕获的照片也应仅以纵向方向放置。这是我的代码:

    AVCaptureStillImageOutput *output = self.session.outputs.lastObject;
    AVCaptureConnection *videoConnection = output.connections.lastObject;
    **videoConnection.videoOrientation = AVCaptureVideoOrientationPortrait;**
    [output captureStillImageAsynchronouslyFromConnection:videoConnection
                                    completionHandler:^(CMSampleBufferRef imageDataSampleBuffer, NSError *error) {
                                        if (imageDataSampleBuffer == nil || error)
                                        {
                                            return;
                                        }
                                        NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageDataSampleBuffer];
                                        UIImage *image = [[UIImage alloc] initWithData:imageData];

但是,如果我在风景中拍摄照片,它仍然在风景中。

0 个答案:

没有答案