下面的代码通过3个简单的步骤突出显示了这个问题:
1)获取moments
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 );
}我是不是误解了什么?这看起来很简单。
感谢任何人的帮助!
发布于 2015-07-23 22:52:32
我也遇到了同样的问题,不知道这段代码出了什么问题。我认为这个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];https://stackoverflow.com/questions/29275214
复制相似问题