简体   繁体   中英

Get actual file name when using writeImageToSavedPhotosAlbum for iOS

I'm writing an AR app that takes a screenshot and then places the image in the photo album so that the end user can get to it. I'm using writeImageToSavedPhotosAlbum. The major issue I'm having right now is that I can't seem to get the filename of the image.

I'm getting something like the following from NSURL: assets-library://asset/asset.PNG?id=8AD512D0-205E-424D-B466-F31CCE4F299C&ext=PNG

When I need something like: Image_0050.png

Does anyone know how to get the actual image name? Or, maybe I'm going about this entirely wrong?

Thanks, Nathan

There is no name. All you have is a UIImage object.

The information you need is in ALAssetRepresentation of any ALAsset. All you need to do is get default representation of current asset and then you will have access to all information you want.

ALAsset *asset = <some_asset>;
NSLog(@"filename %@", asset.defaultRepresentation.filename);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM