ios - 为什么 PHAsset fetchAssetsWithOptions 不返回所有 Assets ?

标签 ios photosframework

我的照片流中有 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/

相关文章:

ios - PHImageManager 的 requestImage 在滚动数千张图像时锁定 UI

ios - 检测何时将 iOS 截图添加到相册

ios - Textview scrollRangeToVisible 使范围到顶​​部

ios - 从 UITableView 中删除自定义 View

ios - 在 super.init 初始化 self 之前在方法调用中使用 self

ios - 如何等待RACSequence完成它的任务

ios - UITableViewCell 选中行的文字颜色变化

iOS 照片框架无法获取图像数据/UTI

ios - 苹果照片 : Get list of “face albums” from Photos. 应用程序

ios - 如何请求授权以自定义 View 访问照片/相机胶卷?