その場合、下記で取得できる。
[self.collectionView visibleCells]
だが、さらにIndexPathがわからないと更新できない。
CellからIndexPathを知りたい場合は下記で
[self.collectionView indexPathForCell:cell]
そして更新する場合は下記です。
[self.collectionView reloadItemsAtIndexPaths:indexPaths]
これらを組み合わせて下記のようなメソッドを書いてviewDidAppearとかで呼んでます。
-(void)allCellReload
{
NSMutableArray * indexPaths = [NSMutableArray new];
for (UICollectionViewCell * cell in [self.collectionView visibleCells]) {
[indexPaths addObject:[self.collectionView indexPathForCell:cell]];
}
[self.collectionView reloadItemsAtIndexPaths:indexPaths];
}
以上!!
0 件のコメント:
コメントを投稿