iOS 11/12 : How to fetch list of “People Album” from Photos. 应用程序

标签 ios swift photo face

我需要从 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)

注意!根据您的需要指定collectionTypesuptype

您可以从示例应用程序 source code provided by Apple 获取更多信息

关于iOS 11/12 : How to fetch list of “People Album” from Photos. 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52524071/

相关文章:

iOS控件通过键入来选择值

ios - 使用 moveRowAt 方法修复顶行

excel - 使用VBA根据Excel中的点名称自动将照片添加到圆环图点

ios - 通过 Graph API 和 iOS : (#1) An unknown error occurred 将照片上传到相册时出现 Facebook 错误

ios - 知道照片是自拍还是人像

ios - 无法在 UIView 中将 UITextField 居中

ios - API 许可证 key 在增强型 Kudan 示例中无效

ios - View inside cell 在所有设备中具有相同的宽度,但 cell 具有不同的宽度

swift - 在协议(protocol)中使用 UIView.animateWithDuration

ios - 自适应 uitextview 直到特定高度