我有一长串textfields,所以我使用了tableView。当编辑一个单元格时,Swift tableview会更改随机单元格的值
this is how the screen looks like
当我插入一个文本框在其中一个单元格一些文字,然后向下滚动其他一些细胞得到相同的文本框的值。我不知道为什么会发生这种情况。
这是我现在的代码:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cellId", for: indexPath) as! RelatieToevoegenCell
cell.label.text = items[indexPath.row]
cell.textfield.placeholder = items[indexPath.row]
return cell
}
你如何处理文本字段的编辑?请提供更多的上下文。 –
@DávidPásztor目前我没有对文本框进行任何操作,只需键入其中一个文本框,并在向下滚动时在不同单元格中显示相同的文本 –