gpt4 book ai didi

ios - PhotoKit:fetchAssetCollectionsWithLocalIdentifiers 失败

转载 作者:可可西里 更新时间:2023-11-01 04:57:15 25 4
gpt4 key购买 nike

以下代码通过 3 个简单步骤突出显示了该问题:

1) 获取时刻

2)缓存时刻localIdentifier

3) 使用标识符获取时刻:失败(在设备上,iOS 8.2)

- ( void )momentLocalIdTest
{
PHFetchResult * fetchResult;
PHAssetCollection * moment;
NSString * localIdentifier;

fetchResult = [ PHAssetCollection fetchMomentsWithOptions: nil ];

if( fetchResult.count == 0 )
return;

moment = fetchResult.firstObject;
localIdentifier = moment.localIdentifier;
fetchResult = [ PHAssetCollection fetchAssetCollectionsWithLocalIdentifiers: @[ localIdentifier ] options: nil ];

if( fetchResult.count == 0 )
NSLog( @"AssetCollection with localIdentifier %@ not found!!!", localIdentifier );
}

我是不是误会了什么?看起来很简单......

感谢任何帮助!

最佳答案

我也遇到了同样的问题,无法弄清楚这段代码有什么问题。我认为这个 API 很简单而且很简单(至少 8.0 到 8.4)

这是一个变通代码;您基本上必须从标识符中重新生成 PHAssetCollection 实例

PHFetchOptions *options = [PHFetchOptions new];
options.predicate = [NSPredicate predicateWithFormat:@"localIdentifier = %@", identifier];

PHAssetCollection *collection = [[PHAssetCollection fetchMomentsWithOptions:options] firstObject];
PHFetchResult *results = [PHAsset fetchAssetsInAssetCollection:collection options:nil];

关于ios - PhotoKit:fetchAssetCollectionsWithLocalIdentifiers 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29275214/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com