【发布时间】:2016-08-03 07:48:41
【问题描述】:
我一直在到处寻找,但无法找到答案。
在 IOS PhotosFramework 中,我如何获取图像/PHAsset 并找出它分配给的所有收藏/专辑?
我已经知道如何从那里获取所有专辑的列表,我还可以获取每个专辑中的所有图像。但是我该如何反过来做 - 即对于给定的 PHAsset 如何获取分配给它的专辑/集合的名称。
这是我必须获取相机胶卷中所有专辑列表的代码:
-(void) listAllAlbums{
PHFetchOptions *userAlbumsOptions = [PHFetchOptions new];
userAlbumsOptions.predicate = [NSPredicate predicateWithFormat:@"estimatedAssetCount > 0"];
PHFetchResult *userAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeAlbum subtype:PHAssetCollectionSubtypeAny options:userAlbumsOptions];
NSLog(@"--------- entered %s ------------- ", __PRETTY_FUNCTION__);
[userAlbums enumerateObjectsUsingBlock:^(PHAssetCollection *collection, NSUInteger idx, BOOL *stop) {
NSLog(@"album title %@", collection.localizedTitle);
}];
NSLog(@"--------- end of %s ------------- ", __PRETTY_FUNCTION__);
}
谢谢
【问题讨论】:
标签: objective-c photosframework