正确重置 cellContent (dequeueReusableCell)

Reset cellContent correctly (dequeueReusableCell)

如您所知,如果不以某种方式重置 tableViewCells,则在上下滚动后可能无法正确显示它们。在网上搜索没有找到令人满意的答案后,我想知道如何做到这一点。

我正在使用一个带有重复使用的标识符的 prototypeCell。标题和副标题当前存储在数组中。根据索引路径,从中获取特定的字符串。但是我如何以某种方式重置内容,以显示正确的字符串?目前,"incorrect" 单元格显示上次初始化的单元格的标题。

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {


    let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath: indexPath) as! UITableViewCell

    let row = indexPath.row

    cell.textLabel?.text = cellNames[row]
    cell.detailTextLabel?.text = cellDetails[row]
return cell

感谢您的回答

在您的 cellForRowAtIndexPath: 委托方法中,在返回之前重置单元格的所有已修改属性。就是这样。