iOS8 Photos Framework: How to get the name(or filename) of a PHAsset?

后端 未结 7 848
野趣味
野趣味 2020-11-28 10:06

Im trying to get the image name using PHAssets. But I couldn\'t find metadata for filename or any method to get the image name. Is there a different way to get

相关标签:
7条回答
  • 2020-11-28 10:46

    SWIFT4: first import Photos

    if let asset = PHAsset.fetchAssets(withALAssetURLs: [info[UIImagePickerControllerReferenceURL] as! URL],
                                               options: nil).firstObject {
    
    
                PHImageManager.default().requestImageData(for: asset, options: nil, resultHandler: { _, _, _, info in
    
                    if let fileName = (info?["PHImageFileURLKey"] as? NSURL)?.lastPathComponent {
                        print("///////" + fileName + "////////")
                        //do sth with file name
                    }
                })
            }
    
    0 讨论(0)
提交回复
热议问题