我用Swift编写了以下代码,使用AVFoundation库来捕获图像:
@IBAction func cameraButtonWasPressed(sender: AnyObject) {
if let videoConnection = stillImageOutput.connectionWithMediaType(AVMediaTypeVideo){
stillImageOutput.captureStillImageAsynchronouslyFromConnection(videoConnection){
(imageSampleBuffer : CMSampleBuffer!, _) in
let imageDataJpeg = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(imageSampleBuffer)
var pickedImage: UIImage = UIImage(data: imageDataJpeg)!
let library = ALAssetsLibrary()
library.writeImageToSavedPhotosAlbum(pickedImage.CGImage,
metadata:nil,
completionBlock:nil)
}
}
}
它可以正常工作,但是当我进入相册时,图像显示逆时针旋转了90度。
有人能给我一个提示在哪里找到解决方法吗?