[英]Swift - How to preload UITableViewCells outside of the screen manually?
The UITableViewCells inside my UITableView contain a view (mainView) that has margins to all sides - so the mainView has space to the sides of the screen as well as to the other cells above and below.我的 UITableView 中的 UITableViewCells 包含一个视图 (mainView),它的所有边都有边距 - 所以 mainView 在屏幕的两侧以及上下的其他单元格都有空间。
The mainView has a shadow. mainView 有一个阴影。 This shadow exceeds the cell borders, but by setting "clipToBounds" to false, a part of the shadow is also visible on the next cell in the tableView - that's how I want it to be.
这个阴影超出了单元格边界,但是通过将“clipToBounds”设置为 false,部分阴影在 tableView 中的下一个单元格上也可见 - 这就是我想要的样子。
Now my problem:现在我的问题:
When I'm scrolling up in the tableView, this happens: A dequeued cell (outside/above the screen), let's name it cell1 , loads because it has to be displayed next.当我在 tableView 中向上滚动时,会发生这种情况:一个出队的单元格(屏幕外部/上方),我们将其命名为cell1 ,因为它必须在接下来显示,所以加载。 This cell1 doesn't know, that the cell above that, let's name it cell0 , casts a shadow on cell1 .
这个cell1不知道,它上面的单元格,我们将其命名为cell0 ,在cell1上投下阴影。 So, of course, it's showing no shadow when it becomes visible.
所以,当然,当它变得可见时,它不会显示任何阴影。 The result is the shadow getting cut off, like this:
结果是阴影被切断,如下所示:
Is there any way to preload the views of the cells that have an impact on the cell that should be displayed next?有没有办法预加载对接下来应该显示的单元格有影响的单元格的视图? Like: cell[i] is displayed right now, I'm scrolling up so cell[i - 1] is getting loaded but cell[i - 2] is getting loaded before that, so cell[i - 1] displays a part of the shadow cell[i - 2] is casting.
像: cell[i] 现在显示,我正在向上滚动,所以 cell[i - 1] 正在加载,但 cell[i - 2] 在此之前被加载,所以 cell[i - 1] 显示一部分阴影单元[i - 2] 正在投射。
I hope you understand what my problem is.我希望你明白我的问题是什么。 Thank you in advance!
先感谢您!
First what do we have:首先我们有什么:
What we have to do:我们必须做的:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.