【发布时间】:2017-07-26 03:22:52
【问题描述】:
我使用功能将图像保存到相机胶卷...
UIImageWriteToSavedPhotosAlbum(imurl!,nil,nil,nil)
如何通过函数获取保存图片的名称或URL??
【问题讨论】:
-
请展示您在项目中尝试的快照代码
标签: ios iphone swift swift3 ios9
我使用功能将图像保存到相机胶卷...
UIImageWriteToSavedPhotosAlbum(imurl!,nil,nil,nil)
如何通过函数获取保存图片的名称或URL??
【问题讨论】:
标签: ios iphone swift swift3 ios9
您可以使用 ALAssetsLibrary 框架将图像保存在磁盘上。
请尝试以下方法 -
ALAssetsLibrary().writeImageToSavedPhotosAlbum(editedImage.CGImage, orientation: ALAssetOrientation(rawValue: editedImage.imageOrientation.rawValue)!,
completionBlock:{ (path:NSURL!, error:NSError!) -> Void in
print("Image path - \(path)")
})
【讨论】:
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
let imageUrl = info[UIImagePickerControllerReferenceURL] as! NSURL
// here you got file path that you select from camera roll
let image = info[UIImagePickerControllerOriginalImage] as! UIImage
// here you got image that select from camera roll now just save it
self.dismiss(animated: true, completion: nil)
}
【讨论】: