cell重用

2017-12-20  本文已影响14人  赤焰军少帅林殊

2.将cell的identifier设为唯一的, 保证了唯一性

1 NSString *identifier = [NSString stringWithFormat:@"%ld%ldcell", indexPath.section, indexPath.row];
2 MyTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier forIndexPath:indexPath];
  3.不使用系统的重用机制, 此方法在数据量较大时会造成过大的内存使用

1 MyTableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
  4.删除将要重用的cell上的所有子视图, 得到一个没有内容的cell

1 [(UIView*)[cell.contentView.subviews lastObject] removeFromSuperview];

上一篇 下一篇

猜你喜欢

热点阅读