我正在尝试从我的自定义相机视图控制器获取图像,并且捕获的照片也应仅以纵向方向放置。这是我的代码:
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];
但是,如果我在风景中拍摄照片,它仍然在风景中。