gpt4 book ai didi

iphone - UITableView 流畅的滚动性能

转载 作者:太空狗 更新时间:2023-10-30 03:51:37 25 4
gpt4 key购买 nike

是什么导致加载图像时 UITableView 上的滚动如此不稳定?是因为它们需要添加为 subview 吗?还是因为图片需要缓存?两个?

最佳答案

因为它们是作为 subview 添加的,并且绘制 subview 需要进行大量工作,因为它们必须被合成。当 Core Graphics 或 Core Animation 使用这些 subview 绘制多个单元格时更是如此。

Loren Brichter (atebits)更好地解释它:

Much like on Mac OS X, there are two drawing systems on the iPhone. One is CoreGraphics, the other is LayerKit CoreAnimation. CoreGraphics does drawing on the CPU, CoreAnimation does drawing on whatever it thinks is fastest - most likely the GPU.

The GPU on the iPhone hates blending, that’s why Apple recommends that you keep as many of your views opaque as possible. Sometimes you have no choice - if you have a label over an image you are forced to make the label transparent otherwise you get a big ugly block around your text.

What’s a developer to do? Pre-blend of course… with CoreGraphics into your own view. If you blend your stuff together into a single static view on demand (e.g. when a table view moves a cell onscreen), it’s a little bit more expensive for the first frame, but every frame after that CoreAnimation is just dealing with one big, opaque texture… which it loves. It’s more than just the blending too. If you think about what is happening in terms of overdraw, having one big view per table cell is a big win because CoreAnimation will only touch a single given pixel on the screen once rather than multiple times (potentially, depending on how much overlap your old view hierarchy had).

关于iphone - UITableView 流畅的滚动性能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2918955/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com