UICollectionView
アイテムを動的に/アニメーションで挿入しようとしています。そのため、画像を非同期でダウンロードする機能があり、アイテムをバッチで挿入したいと考えています。
データを取得したら、次のことを行いたいと考えています。
[self.collectionView performBatchUpdates:^{
for (UIImage *image in images) {
[self.collectionView insertItemsAtIndexPaths:****]
}
} completion:nil];
の代わりに の***
配列を渡す必要がありますNSIndexPaths
。これは、挿入する新しい項目の場所を指す必要があります。場所を提供した後、その位置に表示される実際の画像をどのように提供すればよいのでしょうか。
ありがとうございました
アップデート:
resultsSize
self.results
には、 のデータから新しいデータが追加される前のデータ ソース配列 のサイズが含まれnewImages
ます。
[self.collectionView performBatchUpdates:^{
int resultsSize = [self.results count];
[self.results addObjectsFromArray:newImages];
NSMutableArray *arrayWithIndexPaths = [NSMutableArray array];
for (int i = resultsSize; i < resultsSize + newImages.count; i++)
[arrayWithIndexPaths addObject:[NSIndexPath indexPathForRow:i inSection:0]];
[self.collectionView insertItemsAtIndexPaths:arrayWithIndexPaths];
} completion:nil];