且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

停止重用自定义单元格Swift

更新时间:2022-12-28 16:14:09

当一个单元格被重用时,它仍然具有之前使用的旧值。

When a cell is reused, it still has the old values from its previous use.

您必须通过重置显示隐藏控件的标志来准备重用。

You have to prepare it for reuse by resetting that flag which showed your hidden control.

您可以在 tableView中执行此操作: cellForRowAtIndexPath:或单元格的 prepareForReuse 方法。

You can do this either in tableView:cellForRowAtIndexPath: or the cell's prepareForReuse method.

更新:

以下是您可以为TblCell添加的示例:

Here's an example you can add for TblCell:

override func prepareForReuse()
{
    super.prepareForReuse()
    // Reset the cell for new row's data
    self.act1.hidden = true
}