2

文档中所列,PHAsset 支持hidden (or isHidden)获取密钥。但是,当我尝试获取隐藏资产时,我的应用程序因以下日志而崩溃:

*** 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“获取选项中不支持的谓词:隐藏 == 1”

这是示例代码:

PHFetchOptions *options = [[PHFetchOptions alloc] init];
options.wantsIncrementalChangeDetails = YES;
options.includeAllBurstAssets = YES;
options.includeHiddenAssets = YES;
options.predicate = [NSPredicate predicateWithFormat:@"hidden = YES"];

PHFetchResult *fetchResult = [PHAsset fetchAssetsWithOptions:options];

return fetchResult;
4

1 回答 1

1

我在第一个答案中没有仔细阅读问题,也许这会有所帮助

如果您只想要隐藏的专辑,为什么不使用?子类型:PHAssetCollectionSubtypeSmartAlbumAllHidden

PHFetchOptions *options = [[PHFetchOptions alloc] init];
options.wantsIncrementalChangeDetails = YES;
options.includeAllBurstAssets = YES;
options.includeHiddenAssets = YES;
options.predicate = [NSPredicate predicateWithFormat:@"mediaType == %d",PHAssetMediaTypeImage];

PHFetchResult *albums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum subtype:PHAssetCollectionSubtypeSmartAlbumAllHidden options:nil];
于 2015-06-17T10:25:38.517 回答