在Apple的Photos框架中,资产按此层次结构组织:
PHCollectionList
(例如“所有相册”)PHAssetCollection
(例如“我的专辑”)PHAsset
(例如“一些照片”)我有兴趣将多个PHAssetCollection
合并为一个PHAssetCollection
。
到目前为止,我的方法是做以下事情:
let albumsToRequest = ... // PHFetchRequest<PHCollection>
let transientCollectionList = PHCollectionList.transientCollectionList(
withCollectionsFetchResult: ,
title: "All Photos In Selected Albums"
)
// Of course, this is just the first album in `albumsToRequest`:
let transientCollection = PHAssetCollection.fetchCollections(in: transientCollectionList, options: nil).firstObject! as! PHAssetCollection
// But I’d love for this result to contain a flattened list of *all* the photos in `albumsToRequest`:
let result: PHFetchRequest<PHAssetCollection> PHAsset.fetchAssets(in: transientCollection, options: fetchOptions)
有没有办法将多张相册合并到一个扁平的集合中,以便在单个集合视图中显示? (例如,我想按拍摄日期交错照片。)