UITableViewCell性能优化

5.UITableViewCell性能优化

1> 定义一个循环利用标识

static NSString *ID = @"C1";

2> 从缓存池中取出可循环利用的cell

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];

3> 如果缓存池中没有可循环利用的cell

if (cell == nil) 
{
  cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
}

4> 覆盖cell上面的数据

cell.textLabel.text = [NSString stringWithFormat:@"第%d行数据", indexPath.row];

 

 

posted @ 2014-03-24 22:58  嘟嘟夜未央  阅读(195)  评论(0编辑  收藏  举报