cell重用

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];

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容