ibireme / YYKit

A collection of iOS components.
MIT License
13.99k stars 3.69k forks source link

TableView reload 时,YYLabel 有闪动 #64

Closed BestKai closed 8 years ago

BestKai commented 8 years ago

在demo的微博列表里,reload tableView tableView 会发生闪屏的现象。这是为什么?

ibireme commented 8 years ago

TableView 内的所有文本控件,都是异步绘制的,我猜可能与这个有关。

BestKai commented 8 years ago

有没有优化的方案?

ibireme commented 8 years ago

既然是 "异步绘制",这个问题基本上是避免不的。。

几个方案:

  1. 尽量避免用 [tableView reloadData] 方法,用 insertRows、deleteRows、reloadRows 替代。
  2. 禁用文本的异步绘制,但这会降低界面的流畅性。此处可以在 reloadData 之前禁用,在之后再启用。
  3. reloadData 之前,截取 tableView 作为图片覆盖,在 reloadData 之后,等待 0.3 秒左右再移除。或者,直接在 tableView 的 layer 上加个渐变动画。
  4. label. clearContentsBeforeAsynchronouslyDisplay = NO; 这样做会没有闪动,但是内容更新可能稍有滞后。这个可以实际测试一下看看效果。
yangchao0033 commented 8 years ago

原来截图覆盖是在这用的!

Quanhua-Guan commented 7 years ago

可以配合IGListKit使用, 赞! https://github.com/Instagram/IGListKit.git

meigesir commented 7 years ago

所以果断不再使用这个库,而且YYLabel竟然Text和AttributedString不能切换使用,否则会出现颜色不对、大小不一各种issue,浪费了时间,决定弃用,起因是同事推荐使用

frankfan1990 commented 5 years ago

所以果断不再使用这个库,而且YYLabel竟然Text和AttributedString不能切换使用,否则会出现颜色不对、大小不一各种issue,浪费了时间,决定弃用,起因是同事推荐使用

噗~

hustlzp commented 4 years ago

使用 iOS 13 的 DiffableDataSource 也还是有闪烁。