曾经尝试各种方法优化滚动视图的性能,都没什么好的效果。
今天在官方文档的 tableView 一章节找到些内容。
大致内容是:
- 减少cell 的 subview 。
- 使用 drawInRect 替代
- 避免使用透明效果
具体效果如何,测试中。
原文如下
-
Draw the entire cell only when appropriate
. Your subclass of UITableViewCell could draw all of its content in its drawRect: method, but you should be aware of the potential drawbacks of this approach. Custom drawing applies to the cell’s layer, which can be obscured by any views placed over it. For example, in table views in the grouped style, the background view (the backgroundView property) obscures any drawing performed in drawRect:. The blue selection background will also obscure any drawing. Moreover, custom drawing that occurs during animation (such as when the table view enters and exits editing mode) drastically decreases performance.
-
An alternative is a subclass that composes the content of the cell from subviews, laying those views out in the desired way. Because those views are cached, they can simply be moved around (when, for instance, the cell goes into editing mode). “Programmatically Adding Subviews to a Cell’s Content View” illustrates one such approach and notes another.
-
However, if the content of a cell is composed of more than three or four subviews, scrolling performance might suffer. In this case (and especially if the cell is not editable), consider drawing directly in one subview of the cell’s content view. The gist of this guideline is that, when implementing custom table-view cells, be aware that there is a tradeoff between optimal scrolling performance and optimal editing or reordering performance.
-
Avoid transparency
. Subviews of table-view cells have a compositing cost that you can largely mitigate by making the views opaque. Even one transparent subview per cell impacts scrolling performance. Always use opaque subviews if at all possible.
-
Mark the cell as needing display when viewable properties change
. If you have a custom reusable table cell and it displays a custom property as part of the cell content, you must be sure to send a setNeedsDisplay message to the cell if the value of the property changes. Otherwise UIKit doesn’t know that the cell is “dirty” and therefore won’t invoke the cell’s drawRect: method to have it redraw itself with the new value. A good place to call setNeedsDisplay is in a (non-synthesized) setter method associated with the property.
分享到:
相关推荐
自己写的东西不知道能不能用到,总之先暂时纪录下来吧,U盘光荣了
对应这种页面结构应该毫无疑问是最底层是一个纵向滚动的scrollView,它的页面上面放一个固定高度的header,紧接着下面一个支持横向滚动切换的容器scrollView,容器上面才是各个页面具体的tableView,如下图: ...
cocos2d-x ScrollView与tableView的使用范例
ScrollView+TableView列表控制滑动效果,类似美团主界面操作,实现主页与详情页交互,上拉为详情,下拉手势主页; 再加移动手势的动画效果...
由于最近需求是做题库,为了性能更优,体验更好,So,借鉴大神的思路,此项目便横空出世。
最好用一个tableview实现。一个tableview不够用了再嵌套,适用复杂场景。 首先我说下不适用的,免得大家浪费时间。 1.不适用上下拉刷新加载更多的页面。 2.不适用点击cell获取点击事件的页面,可以加入button点击...
它的作用是提供一种系统性的方法,以有效地应对挑战、优化流程或实现目标。以下是方案的主要作用: 问题解决: 方案的核心目标是解决问题。通过系统性的规划和执行,方案能够分析问题的根本原因,提供可行的解决...
Cocoscreator scrollview 性能优化
作者shunFSKi,源码FSScrollViewNestTableView,这是一个scrollView嵌套tableView的手势冲突解决方案。
动态控制,优化scrollView 适用于Unity3D,解决场景卡顿的问题
cocos2dx scrollview优化
主要是运用了scrollview和tableview,实现瀑布流的代码编写
ScrollView优化
重用tableView
(ScrollView优化)UnityTest1.rar是一个基于unity5.5.6f1 vs2017的ScrollView优化测试,包含水平和竖直方向的应用!这里只给出了竖直方向的应用示例,水平方向同理!
UGUI ScrollView 优化重复利用 ,后续持续优化版本。。。。。