我需要从 native photos.app 中获取“人物相册”。有没有办法获取该结果?我尝试了多种方法来获取“人物相册”,但没有成功。
我使用以下方法来获取专辑,但我刚刚获得了名为“People”的顶级 CollectionList,但无法获取“People”CollectionList 中的集合。
let peopleFolder = PHCollectionList.fetchCollectionLists(
with: .smartFolder,
subtype: .smartFolderFaces,
options: nil).firstObject!
最佳答案
使用带有选项和特定谓词的获取请求:
let fetchOptions = PHFetchOptions()
fetchOptions.predicate = NSPredicate(format: "title = %@", "People")
let resultCollections = PHAssetCollection.fetchAssetCollectionsWithType(
.smartAlbum,
subtype: .albumRegular,
options: fetchOptions)
注意!根据您的需要指定collectionType
和suptype
。
您可以从示例应用程序 source code provided by Apple 获取更多信息
关于iOS 11/12 : How to fetch list of “People Album” from Photos. 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52524071/