我使用CollectionView来显示数据。当用户按下某个按钮时,我刷新了CollectionViewCell以反映这样的变化:
[self.collectionView reloadItemsAtIndexPaths:[NSArray arrayWithObject:indexPath]];
这可以很好地重新加载单元格,除了它没有重新加载它的页脚视图。我实现了以下方法
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"FOOTER CALLED");
重新加载单元格时,这不会被调用。
如果我用[self.collectionview reloadData]重新加载整个集合视图,Eveything会起作用,但效率不高。
如何确保indexPath上我的UICollectionViewCell的页脚也会刷新?
答案 0 :(得分:1)
您必须使布局无效或重新加载该部分。
布局无效。
[[_collectionView collectionViewLayout] invalidateLayout]
重新加载该部分。使用reloadSections:
更新UICollectionView
。
[self.collectionView reloadSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 3)]];