如您所知,如果不以某种方式重置tableViewCells,则在上下滚动后可能会错误显示。在网上搜索但没有找到满意的答案后,我想知道该怎么做。
我正在使用一个带有可重复使用的标识符的prototypeCell。标题和副标题当前存储在数组中。根据索引路径,从它们中获取特定的字符串。但是我如何以某种方式重置内容,以显示正确的字符串?目前,“不正确”的单元格显示上次初始化的单元格的标题。
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:
委托(delegate)方法中,在返回之前重置单元格的所有已修改属性。就是这样。
关于ios - 正确重置单元内容(dequeueReusableCell),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32121972/