zoukankan      html  css  js  c++  java
  • UITableView 性能优化

    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/

  • 相关阅读:
    使用八爪鱼采集所需信息
    一些小疑问&解答
    第一页的简单爬取
    【不解决了】对Spark源码进行编译
    python学习中的序列函数
    关于python中的小知识总结
    python学习13之数据泄密
    python学习12之梯度推进
    python学习11之交叉验证
    python学习10之管道清理建模
  • 原文地址:https://www.cnblogs.com/Jenaral/p/5122018.html
Copyright © 2011-2022 走看看