【发布时间】:2015-07-20 21:18:38
【问题描述】:
我设置了一个 tableView,这样当一个单元格被触摸时,它会在高度上扩展以显示更多信息。 tableView 有 5 个部分。
我有一个错误:当单元格展开时,该单元格下方的所有 headersCells 都将不可见。控制台输出以下内容:“[31233:564745] 没有重复使用表格单元格的索引路径”
在我的故事板中,我有 2 个自定义单元格:"myCell" 用于数据承载单元格,"headerCell" 用于标题。
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let thisGoal : GoalModel = goalArray[indexPath.section][indexPath.row]
if self.currentPath != nil && self.currentPath == indexPath {
self.currentPath = nil
} else {
self.currentPath = indexPath
}
tableView.beginUpdates()
tableView.endUpdates()
}
如果我在开始/结束更新之间输入tableView.reloadData(),它会正常工作,尽管标题背景变黑并失去动画。
我拥有声明的所有标题:func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView?
我错过了什么?我真的很希望 tableView 仍然有动画,并保持背景clearColor()。
提前致谢。我确实通读了客观 C 的答案,但无法让它们为我工作。非常感谢 SWIFT 的帮助。
我认为问题在于重复使用表格单元格的无索引路径。
【问题讨论】:
标签: ios uitableview swift header nsindexpath