ios - 如何优化tableview滚动速度
天蓬老师
天蓬老师 2017-04-17 12:08:00
0
2
228

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

天蓬老师
天蓬老师

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

reply all(2)
小葫芦

The cells of the table can be reused. When scrolling, all the cells that need to be used have been generated. All you need to do is to fill in the content into the cell to be displayed. If the content (pictures, text) is also It has been loaded into the memory. What are the factors that can cause unsmoothness? Unless you do something blocking in the operation of "filling in" the cell. . .

Ty80
  • 重用 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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!