[英]get file name when using writeImageToSavedPhotosAlbum
in an ios swift application, I am using writeImageToSavedPhotosAlbum
to save a UIImage on the iphone 在ios swift应用程序中,我正在使用
writeImageToSavedPhotosAlbum
在iPhone上保存UIImage
let assets : ALAssetsLibrary = ALAssetsLibrary()
let imgRef : CGImage = myImage!.CGImage
let orientation : ALAssetOrientation = ALAssetOrientation(rawValue: myImage!.imageOrientation.rawValue)!
assets.writeImageToSavedPhotosAlbum(imgRef, orientation: orientation, completionBlock: nil)
Is there a way I can get the saved image filename? 有没有办法获取保存的图像文件名? or maybe to set it myself?
还是自己设定?
Thank you for any help 感谢您的任何帮助
If you look at the spec of the method you're using you will see that the completion block you aren't using is of type ALAssetsLibraryWriteImageCompletionBlock
, which has the parameters NSURL *assetURL, NSError *error
. 如果查看所使用方法的规范,您会发现未使用的完成块的类型为
ALAssetsLibraryWriteImageCompletionBlock
,其参数为NSURL *assetURL, NSError *error
。
So specify a completion block and you get the asset URL from which you can derive some information. 因此,指定一个完成块,您将获得资产URL,可以从中获取一些信息。
You can get the file path information using the completion block parameter. 您可以使用完成块参数获取文件路径信息。 Instead of passing
nil
pass the block like: 与其传递
nil
传递块:
assets.writeImageToSavedPhotosAlbum(imgRef, orientation: orientation, completionBlock:
{ (path:NSURL!, error:NSError!) -> Void in
println("\(path)")
})
Check the ALAssetLibrary Class Reference for more information 检查ALAssetLibrary类参考以获取更多信息
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.