【发布时间】:2015-01-29 21:55:30
【问题描述】:
我已经编写了这段代码来使用 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 度。
有人可以告诉我在哪里可以解决这个问题吗?
【问题讨论】:
-
设置视频连接方向和创建新的 UIImage 似乎不起作用。不确定我是否做错了什么。
标签: ios swift uiimage avfoundation alassetslibrary