5

iOS デバイスにある画像の固定バッチを取得したいと思います。私は新しいPhotos Frameworkを使用していますが、すでに次の回避策を見つけています。

PHFetchOptions *allPhotosOptions = [PHFetchOptions new];

allPhotosOptions.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"creationDate" ascending:NO]];

// Fetches all photos -> i would like to fetch only some of them
PHFetchResult *allPhotosResult = [PHAsset fetchAssetsWithMediaType:PHAssetMediaTypeImage options:allPhotosOptions];

NSIndexSet *indexSet = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(currentIndex, batch_size)];

// Iterates over a subset of the previously fetched photos
[allPhotosResult enumerateObjectsAtIndexes:indexSet options:0 usingBlock:^(PHAsset *asset, NSUInteger idx, BOOL *stop)
{
    // Do stuff    
}

それは正常に動作しますが、最初にすべての写真を取得してfetchAssetsWithMediaTypeから、アプリがロードする結果のサブセットを選択します。これはかなり重いようです...

写真をバッチごとに直接取得し、すべてを取得してから反復するのではなく、直接取得する方法があるかどうかを知りたかったのです。さらに、最後にフェッチしたバッチのインデックスを保持できれば、次のバッチをどこでフェッチするかを知ることができれば完璧です。

ご協力いただきありがとうございます!

4

1 に答える 1

-1

より詳細な検索の後、私は最終的に私が探していたものを ここでsetFetchBatchSize見つけました: One could use from NSSortDescriptor.

于 2016-09-26T13:31:35.217 に答える