iPhone : Photos framework : how to get only those album/images which created by my app only not by others?

做~自己de王妃 提交于 2019-12-04 15:57:01

问题


I am creating a application like photos app. My application creates albums and captures images and saves them in albums in photos app. For this I am using Photos framework. When i am fetching albums it gives me albums which created by my app as well as other apps. So I want only those album/images which created by my app only not by other apps.


回答1:


There is no straight-forward way to do this. But this is a workaround.

PHFetchResult *topLevelUserCollections = [PHCollectionList fetchTopLevelUserCollectionsWithOptions:nil];
    self.collectionsFetchResults = @[topLevelUserCollections];

    for (PHFetchResult *fetchResult in self.collectionsFetchResults) {
            for (PHAssetCollection *assetCollection in fetchResult) {
                BOOL shouldShowCollection = NO;
                if ([assetCollection.localizedTitle isEqualToString:@"YOUR_APP_NAME"]) {
                    shouldShowCollection = YES;
                }

                if (shouldShowCollection) {
                   //collectionsToShow are the collections that you will show up in your table view
                   [self.collectionsToShow addObject:assetCollection];
                }
            }
        }


来源:https://stackoverflow.com/questions/28987198/iphone-photos-framework-how-to-get-only-those-album-images-which-created-by

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