• 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/

  • 相关阅读:
    Django Rest Framework
    模块化开发
    单文件组件
    在create-react-app创建的React项目应用中配置JQ、Sass
    React 生命周期
    React项目的打包
    JS中的事件冒泡和事件捕获
    webpack 入门教程
    如何优雅地使用 VSCode 来编辑 vue 文件?
    页面跳转选中对应的导航
  • 原文地址:https://www.cnblogs.com/Jenaral/p/5122018.html
Copyright © 2020-2023  润新知