问题描述
我的问题是我们如何从画廊选择的 PHAsset 中获取文件名
var allSmallPic: [PHAsset] = []
PHImageManager.default().requestimage(for: allSmallPic[indexPath.row],targetSize: PHImageManagerMaximumSize,contentMode: .aspectFit,options: nil) { (image,info) in
cell.ImageVieww.image = image
cell.Labell.text = "\(String(describing: info!))"
print(info!)
}
解决方法
let resource1 = PHAssetResource.assetResources(for:self.allSmallPic[indexPath.row])
print("Get resources\(resource1)")
cell.Labell.text = resource1[0].originalFilename
,
众所周知,PHAsset 是照片库中图像、视频或实况照片的表示。
所以我想像这样将文件名显示到我的 tableViewCell 中
当没有找到结果时,我开始阅读文档并找到 PHAssetResource,它们帮助我获取图像名称
let resource1 = PHAssetResource.assetResources(for:self.allSmallPic[indexPath.row])
print("Get resources\(resource1)")
cell.Labell.text = resource1[0].originalFilename
allSmallPic 是存储 PHAsset 的全局数组