首页 > 其他 > 详细

UITableView 性能优化

时间:2016-01-11 20:02:07      阅读:207      评论:0      收藏:0      [点我收藏+]
  1. 网络图片异步加载,SDWebImage。
  2. 文字直接 drawInRect/drawAtPoint 绘制,参考 ABTableViewCell,AdvancedTableViewCells
  3. 本地图片也可以直接绘制,或者用 CALayer 来添加显示。
  4. cell 重用机制。
  5. cell 内容尽量避免透明效果。
  6. 如非必要,减少 reloadData 全部 cell,只 reloadRowsAtIndexPaths。
  7. 如果 cell 是动态行高,计算出高度后缓存。tableView 会在加载的时候把全部 cell 的高度通过heightForRowAtIndexPath: 都计算出来,即使 cell 还没有展示。
  8. 如果 cell content 的展示位置也不固定,第一次计算后也要缓存。
  9. cell 高度固定的话直接用 cell.rowHeight 设置高度,不要再实现tableView:heightForRowAtIndexPath: delegate.
  10. cell content 的解析操作(尤其是复杂的解析)异步进行+预执行,解析结果要缓存。
  11. 可以预先加载需要的网络资源(图片等),SDWebImagePrefetcher.

There are performance implications to using tableView:heightForRowAtIndexPath: instead of therowHeight property. Every time a table view is displayed, it calls tableView:heightForRowAtIndexPath: on the delegate for each of its rows, which can result in a significant performance problem with table views having a large number of rows (approximately 1000 or more). via Apple Document

 

 

转载自:http://fann.im/blog/2012/09/11/uitableview-optimization-notes/

UITableView 性能优化

原文:http://www.cnblogs.com/Jenaral/p/5122018.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!