UITableView 性能优化笔记
source link: https://fann.im/blog/2012/09/11/uitableview-optimization-notes/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
UITableView 性能优化笔记
Sep 11, 2012
Hacking Week 技术总结最后一篇,记一下 UITableView 性能优化需要注意和改进的地方。
- 网络图片异步加载,SDWebImage。
- 文字直接 drawInRect/drawAtPoint 绘制,参考 ABTableViewCell,AdvancedTableViewCells。
- 本地图片也可以直接绘制,或者用 CALayer 来添加显示。
- cell 重用机制。
- cell 内容尽量避免透明效果。
- 如非必要,减少 reloadData 全部 cell,只 reloadRowsAtIndexPaths。
- 如果 cell 是动态行高,计算出高度后缓存。tableView 会在加载的时候把全部 cell 的高度通过
heightForRowAtIndexPath:
都计算出来,即使 cell 还没有展示。 - 如果 cell content 的展示位置也不固定,第一次计算后也要缓存。
- cell 高度固定的话直接用
cell.rowHeight
设置高度,不要再实现tableView:heightForRowAtIndexPath:
delegate. - cell content 的解析操作(尤其是复杂的解析)异步进行+预执行,解析结果要缓存。
- 可以预先加载需要的网络资源(图片等),SDWebImagePrefetcher.
There are performance implications to using
tableView:heightForRowAtIndexPath:
instead of therowHeight
property. Every time a table view is displayed, it callstableView: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
Was this page helpful?
Recommend
-
160
website upgrading… 京ICP备110065...
-
154
优雅的使用UITableView(OC 上) 2018年01月14日 03:01 · 阅读 12035
-
80
前言 知识是无穷无尽,技术需要积累,记录一点一滴,让成长的时间轴上变得充实一些。 今天就讲讲UITableView/UICollectionView的一些使用技巧。结合自己项目情况进行展开。 Header/Footer高度、悬停设置 高度设置 有时候我们需要设
-
77
-
61
-
44
-
69
-
45
README.md Bento ? 弁当 is a single-portion take-out or home-packed meal common in Japanese cuisine. A traditional bento holds ric...
-
51
前言 分享iOS开发中遇到的问题,和相关的一些思考,本次内容包括: UITableView滚动问题、ARC、xcconfig、Push证书。 正文 UITableView UITableView在reloadData 的时候,如果hei...
-
37
[UITableView性能优化] Cell是我们经常会使用的控件,以下几种方法可以大大提高性能 使用不透明视图。 不透明的视图可以极大地提高渲染的速度。因此如非必要,可以将table...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK