UICollectionView 刷新指定单元格或刷指定分区
原创
©著作权归作者所有:来自51CTO博客作者拔山河的原创作品,请联系作者获取转载授权,否则将追究法律责任
刷新指定单元格:
为了避免重新加载时出现不需要的动画(又名“闪烁”)
= [UIView areAnimationsEnabled];
[UIView setAnimationsEnabled:NO];
NSIndexPath *indexPath=[NSIndexPath indexPathForRow:2 inSection:0];
[self.collectionView reloadItemsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil]];
[UIView setAnimationsEnabled:animationsEnabled];
刷指定分区:
if(isCommonUnitEmptyArray(self.model.data))
{
[self.collectionView reloadData];
}
else{
NSIndexSet *indexSet=[[NSIndexSet alloc]initWithIndex:1];
//为了避免重新加载时出现不需要的动画(又名“闪烁”)
BOOL animationsEnabled = [UIView areAnimationsEnabled];
[UIView setAnimationsEnabled:NO];
[self.collectionView reloadSections:indexSet];
// [self.collectionView reloadSections:indexSet withRowAnimation:UITableViewRowAnimationAutomatic];
[UIView setAnimationsEnabled:animationsEnabled];
}