如documentation中所列,PHAsset支持hidden (or isHidden)
提取密钥。但是,当我尝试获取隐藏的资源时,我的应用程序会崩溃并显示以下日志:
***由于未捕获的异常终止应用' NSInvalidArgumentException',原因:'获取选项中不支持的谓词:hidden == 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;
答案 0 :(得分: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];