【发布时间】:2017-03-21 03:44:55
【问题描述】:
这是我在自定义相机中用于拍摄照片的代码,但它可以正确拍摄照片,但如果假设用户旋转设备(但相机仍会像 iphone 相机一样处于纵向)并拍照,我希望以纵向拍摄该照片。如何我这样做?
let stillImageOutput = self._getStillImageOutput()
if let videoConnection = stillImageOutput.connection(withMediaType: AVMediaTypeVideo) {
// videoConnection.videoOrientation = AVCaptureVideoOrientation.portrait
stillImageOutput.captureStillImageAsynchronously(from: videoConnection , completionHandler: { [weak self] sample, error in
if let error = error {
DispatchQueue.main.async(execute: {
self?._show(NSLocalizedString("Error", comment:""), message: error.localizedDescription)
})
imageCompletion(nil,error as NSError?)
return
}
let imageData = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(sample)
var capturedImage = UIImage(data: imageData!)[![This how photo showing if i capture by rotating Device][1]][1]
【问题讨论】:
-
不。这是不同的问题。
-
这可能会有所帮助。它在 Objective-C 中,但你明白了。 stackoverflow.com/a/7932657/7005670