ios - 如何优化tableview滚动速度
天蓬老师
天蓬老师 2017-04-17 12:08:00
[iOS讨论组]

新浪微博,VVebo等等微博客户端他们的tableview界面滚动十分流畅,求教大神是怎么做到的?

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

全部回复(2)
高洛峰

table的cell是可以复用的,滚动起来的时候, 需要用到的cell都已经生成了,需要做的只是把内容填写到将要显示的cell上去, 如果这个内容(图片,文字)也都已经加载到内存里了,有什么是能够导致不流畅的因素呢?除非你在“填写”cell这个操作里做了什么阻塞的事情。。。

PHP中文网
  • 重用 cell
  • 避免重复布局 cell 的内容
  • 保持 cell 内容为非透明

Cells and Table View Performance

The proper use of table view cells, whether off-the-shelf or custom
cell objects, is a major factor in the performance of table views.
Ensure that your application does the following three things:

Reuse cells. Object allocation has a performance cost, especially if
the allocation has to happen repeatedly over a short period—say, when
the user scrolls a table view. If you reuse cells instead of
allocating new ones, you greatly enhance table view performance.

Avoid relayout of content. When reusing cells with custom subviews, refrain
from laying out those subviews each time the table view requests a
cell. Lay out the subviews once, when the cell is created.

Use opaque subviews. When customizing table view cells, make the subviews of the > cell opaque, not
transparent.

Ref:https://developer.apple.com/library/ios/documentation/userexperience/conceptual/tableview_iphone/TableViewCells/TableViewCells.html

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号