iOS Photos Framework: is it possible to access photos from “People” smart folder?

旧巷老猫 提交于 2019-11-30 13:21:40

问题


I'm trying to access PHAssetCollections from PHCollectionList. The main idea is to fetch all collections (and assets inside) from "People" smart folder on my iPhone (iOS 10.2). To fetch PHCollectionList I'm using current code:

PHFetchResult *listFetchResult = 
[PHCollectionList fetchCollectionListsWithType:PHCollectionListTypeSmartFolder 
                                       subtype:PHCollectionListSubtypeSmartFolderFaces
                                       options:nil];
PHCollectionList *list = listFetchResult[0];
NSLog(@"title: %@",list.localizedTitle);

This works as expected. Console output: "title: People". list.canContainAssets returns NO and list.canContainCollections returns YES.
Then, I'm trying to fetch asset collections from list:

PHFetchResult *collectionFetchResult = 
[PHCollection fetchCollectionsInCollectionList:list options:nil];

collectionFetchResult.count always returns 0. But if I open Photos app i see 10 collections inside "People" folder.

Is it possible to access collections (and photos inside them) from "People" smart album in Photos app?


回答1:


The "synced Faces" album refers to an older feature (which is still supported in some configurations): the ability to sync albums defined in iPhoto for OS X (10.10 and earlier) to an iOS device through iTunes. One of those albums is iPhoto's Faces feature (the spiritual ancestor of modern Photos' People feature).

There is no API for accessing "albums" created by the People feature in Photos for iOS 10. (Ditto for Moments, scene classification, and most of the other Photos app features in iOS 10.) To lobby for such support, your best bet is to file bugs.



来源:https://stackoverflow.com/questions/41287387/ios-photos-framework-is-it-possible-to-access-photos-from-people-smart-folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!