4
iOSデバイス上にあるピクチャの固定バッチを取得したい。私は新しいPhotos Frameworkを使用しています、と私はすでに、この回避策を見つけました:iOSピクチャのバッチを取得する
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
ですべての写真を取得してからロードするために私のアプリのために結果のサブセットを選択し、非常に思われます重い...
写真バッチをバッチ単位で直接取得し、それらをすべてフェッチせずに反復する方法があるかどうかを知りたかったのです。 最後にフェッチされたバッチのインデックスを保持して、次のバッチをどこで取得するかを知ることができれば完璧です。
ありがとうございました!