用相机拍照后,我用下面的代码保存图像:
UIImageWriteToSavedPhotosAlbum(image, self,"image:didFinishSavingWithError:contextInfo:", nil)
这会将图像保存在相机胶卷中。此外,我想将 URL 保存到核心数据中的这个已保存图像。是否可以检索到的 URL(或路径)以便我只需要保存此 URL 而不是核心数据中的完整图像?
最佳答案
在阅读了很多用 ObjectivC 编写的答案之后,我终于想出了如何使用 Xcode 6.2 在 Swift 中编写这个:
ALAssetsLibrary().writeImageToSavedPhotosAlbum(image.CGImage, orientation: ALAssetOrientation(rawValue: image.imageOrientation.rawValue)!,
completionBlock:{ (path:NSURL!, error:NSError!) -> Void in
println("\(path)")
})
关于ios - Swift 中 UIImageWriteToSavedPhotosAlbum 后图像的 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29009621/