iOS UITableViewCell刷新某些行的cell或section
原创
©著作权归作者所有:来自51CTO博客作者拔山河的原创作品,请联系作者获取转载授权,否则将追究法律责任
//一个section刷新
NSIndexSet *indexSet=[[NSIndexSet alloc]initWithIndex:2];
//为了避免重新加载时出现不需要的动画(又名“闪烁”)
BOOL animationsEnabled = [UIView areAnimationsEnabled];
[UIView setAnimationsEnabled:NO];
[self.tableView reloadSections:indexSet withRowAnimation:UITableViewRowAnimationAutomatic];
[UIView setAnimationsEnabled:animationsEnabled];
//一个或多个cell刷新
NSIndexPath *indexPath1=[NSIndexPath indexPathForRow:2 inSection:0];
NSIndexPath *indexPath2=[NSIndexPath indexPathForRow:1 inSection:2];
//为了避免重新加载时出现不需要的动画(又名“闪烁”)
BOOL animationsEnabled = [UIView areAnimationsEnabled];
[UIView setAnimationsEnabled:NO];
[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath1,indexPath2,nil] withRowAnimation:UITableViewRowAnimationNone];
[UIView setAnimationsEnabled:animationsEnabled];