iOS UITableView的Cell局部更新方案

// 局部更新方案一,section收合的适合会闪退
NSArray *visible   = [self.MainTableview indexPathsForVisibleRows];
[self.MainTableview beginUpdates];
[self.MainTableview reloadRowsAtIndexPaths:visible withRowAnimation:UITableViewRowAnimationNone];
[self.MainTableview endUpdates];


// 局部更新方案二
NSArray *visible   =  [self.MainTableview indexPathsForVisibleRows];
for (NSIndexPath * path in visible) {
    LotteryDrawScoreViewCell *cell = [self.MainTableview cellForRowAtIndexPath:path];
    NSInteger row = [path row];
    NSInteger section = [path section];
    ScoreListModel *scoreListModel = [ScoreListModel mj_objectWithKeyValues:_currentData[section]];
    // 将字典转为模型
    ScoreMatchListModel *model = [ScoreMatchListModel mj_objectWithKeyValues:scoreListModel.matches[row]];
    [self showAnimate:cell model:model];  // 更新方法
}

猜你喜欢

转载自blog.csdn.net/a121267963/article/details/82021115