TVanimationsGestures 示例代码 Bug/奇怪的行为重叠单元格

发布于 2024-12-25 16:23:52 字数 865 浏览 0 评论 0原文

我正在尝试在我的应用程序上实现漂亮的手风琴效果。我的目标是当用户点击单元格时“打开”单元格,随着单元格高度的增加显示附加内容(例如文本)。 完美的示例代码是 TableView Animations & Apple 提供的手势示例代码。然而我遇到了一种奇怪的行为,这破坏了整体效果。

看起来,根据表格视图显示其单元格的顺序(顶部-->底部或底部-->向上),单元格文本视图将彼此重叠或不重叠。 由于用文字解释有点困难,所以这里用图像来解释。

这些屏幕截图取自 TVAnimationsGestures 示例代码,未对其进行任何更改。它来自没有故事板的示例代码的第一个版本:

Normal Behaviour

现在带有故事板的版本,首先表现良好,但过了一段时间,在我没有接触代码的情况下,它就开始画这个:

Overlapping cells

我的电脑上有确切的问题定制与我的自定义单元格。

我花了一段时间才明白我认为问题出在哪里。如果单元格从顶部单元格绘制到底部,则不存在此问题。但是,如果单元格从下到上绘制,它们将反向堆叠,因此彼此重叠。我认为无法控制这种行为。 给我提示的是,当我向下滚动并强制顶部单元格重绘时,它们实际上重绘得很好,屏幕看起来像这样:

Mixture

重叠细胞和“好”细胞的混合物。

同样,这一切都直接来自 Apple 示例代码,没有任何更改。 有谁知道发生了什么事吗?

非常感谢您的帮助。

Im trying to implement a nice accordion effect on my app. My goal is to "open up" a cell when the user tap on it, diplaying additionnal content (such as text) as the cell height increase.
The perfect sample code for that is the TableView Animations & Gestures sample code provided by Apple. However I am experiencing a strange behavior, that ruins the whole effect.

It appears that depending on the order in which the tableview will display its cells (top --> Bottom or Bottom-->up) the cells textviews will overlap each other or not.
As its a bit difficult to explain with word so here is it with images.

Those screenshots were taken from the TVAnimationsGestures Sample Code, without any changes made to it. It comes from the first version of the sample code without storyboard:

Normal Behavior

Now the version with the storyboard, first behaved well, but after a while, and without me touching the code it started drawing this :

Overlapping cells

And I have the exact problem on my custom with my custom cells.

It took me a while to understand what I think the problem comes from. If cells are drawn from the Top cell to the bottom, there is no such problem. However if cells are drawn bottom to the top, they will stack in reverse and therefore overlap each other. I don't think it is possible to control this behavior.
What gave me the hint, is that when I scroll down, forcing the top cell to redraw, they actually redraw nicely, and the screen looks like this:

Mixture

A Mixture of overlapping cells and "good" cells.

Again, this all comes directly from Apple sample code, without any changes.
Does anyone knows whats going on?

Thanks a lot for your help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

吹梦到西洲 2025-01-01 16:23:52

您可以通过捏住单元来增加单元高度。

You can increase the cell height by pinching on the cell.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文