如 documentation 中所列, PHAsset 支持 hidden (or isHidden) fetch key。但是,当我尝试获取隐藏 Assets 时,我的应用程序因以下日志而崩溃:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unsupported predicate in fetch options: 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 fetchAssetsWithOptionsptions];
return fetchResult;
Best Answer-推荐答案 strong>
我在第一个答案中没有仔细阅读问题,也许这会有所帮助
如果您只想要隐藏的专辑,为什么不使用?
子类型HAssetCollectionSubtypeSmartAlbumAllHidden
PHFetchOptions *options = [[PHFetchOptions alloc] init];
options.wantsIncrementalChangeDetails = YES;
options.includeAllBurstAssets = YES;
options.includeHiddenAssets = YES;
options.predicate = [NSPredicate predicateWithFormat"mediaType == %d",PHAssetMediaTypeImage];
PHFetchResult *albums = [PHAssetCollection fetchAssetCollectionsWithTypeHAssetCollectionTypeSmartAlbum subtypeHAssetCollectionSubtypeSmartAlbumAllHidden options:nil];
关于ios - 使用 'hidden = YES' 谓词崩溃获取 PHAsset,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/30735939/
|