我有一个如下的动态 tableView,它根据indexpath.row
. 在每个单元格中,我都有一个按钮,可以更改名称作为单元格的删除,如下面的代码所示。当我加载表格时,假设行加载如下:
名称1
名称2
名称3
名称4
名称5
名称6
名称7
名称8
然后我单击按钮并将 Name4 更改为 NewName 例如。单击按钮时它会更改,但是当您在表格中滚动时,当再次涉及indexpath.row
Name4 时(indexpath.row==3
在这种情况下),NewName 会更改回 Name4。每次更改时,如何停止表加载indexpath.row
?或者我怎样才能找到解决这个问题的另一种方法?
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell:NamesCell = tableView.dequeueReusableCellWithIdentifier("Cell") as! NamesCell
cell.NameCell1003 = self
cell.nameLbl.text = self.resultsNameArray[indexPath.row]
return cell
}
func NameCell1003(cell: NamesCell)
{
cell.nameLbl.text= "NewName"
}