我的照片流中有 75 张照片,相机胶卷中有 1 张照片(不在我的照片流中)。所以我总共有 76 张照片。但是按照代码只返回 51 张照片:
PHFetchOptions *options = [[PHFetchOptions alloc] init];
options.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"creationDate" ascending:YES]];
assetsFetchResults = [PHAsset fetchAssetsWithOptions:options];
我知道:
If this method is called by an app linked on or after iOS 8.1, the results do not include photos synchronized to the device from iTunes or photos stored in an iCloud Shared Photo Stream.
但上面的照片都不是来自 iCloud 共享照片流。
最佳答案
不是最漂亮的,但尝试以下获取所有 Assets :
NSMutableArray *_assets = [NSMutableArray new];
PHFetchResult *fr = [PHAssetCollection fetchMomentsWithOptions:nil];
for (PHAssetCollection *collection in fr) {
PHFetchResult *_fr = [PHAsset fetchAssetsInAssetCollection:collection options:nil];
for (PHAsset *asset in _fr) {
[_assets addObject:asset];
}
}
关于ios - 为什么 PHAsset fetchAssetsWithOptions 不返回所有 Assets ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29631702/