开发者社区 问答 正文

屏幕修改后不需要重新加载数据

在表单元中放了自定义颜色,可以修改环境。代码实现了修改颜色功能。但是我发现每次获取颜色时都要重新加载数据。有没有别的方法?

代码:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    // testing for old selected color
    if (checkedIndexPath)
    {
        // returning old checked cell back to blue
        UITableViewCell *uncheckCell = [tableView cellForRowAtIndexPath:checkedIndexPath];
        uncheckCell.backgroundColor = [UIColor blueColor];
    }

    // changing selected cell background color
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    cell.backgroundColor = [UIColor greenColor];
    checkedIndexPath = indexPath;

    // reloadingtable data
    [self.tableVerseView reloadData];
}

展开
收起
爵霸 2016-03-24 11:25:11 1882 分享 版权
1 条回答
写回答
取消 提交回答
  • [self.tableVerseView reloadData];
    如果数据集合没有变化,只刷新对应的行就好了。
    UITableView的方法试试reloadRowsAtIndexPaths:withRowAnimation:

    2019-07-17 19:12:26
    赞同 展开评论
问答地址: