iOS UITableViewCell 重叠 [英] iOS UITableViewCell overlapping

查看:28
本文介绍了iOS UITableViewCell 重叠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试重新加载 tableView 的数据时出现奇怪的重叠,导致单元格的高度发生变化(使用 UITableViewAutomaticDimension),然后内容与其上方的单元格重叠,无法弄清楚怎么做:/

I'm having weird overlapping when i try to reloadData of the tableView, causing the cell's height to change (using UITableViewAutomaticDimension), then the content get overlapped with the cell above it, cant figure out how to do it :/

之前:

从单元格下方重新加载视图后,跳转到上方:

After reload the view from under cell jump to above:

它们基本上是相同的单元格,但顶部的单元格具有 View height = 0 并且没有数据,并且仅在底部单元格全屏(顶部单元格不可见)时才会发生,如果每小时收入单元格可见,则这个bug不会出现

They are basically the same cell but the top one have that View height = 0 and have no data, And it only happen if the bottom cell is fullscreen (top cell is invisible), if the Revenue per hour cell is visible then this bugs wont appear

推荐答案

这可能是设置了相同的单元格标识符造成的,您是否在重用之前刷新单元格?

This is probably due to set the same cell identifier, do you refresh cells before reusing them?

    - (void)prepareForReuse {    }

在你的表格视图单元格类上实现这个方法.希望这对您有所帮助.

Implement this method on your table view cell classes. Hope this would be helpful to you.

这篇关于iOS UITableViewCell 重叠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆