【发布时间】:2015-11-23 01:19:32
【问题描述】:
当我尝试从 tableView 中删除一行时出现错误。 代码如下
override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
if editingStyle == UITableViewCellEditingStyle.Delete {
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
tableView.reloadData()
}
}
Xcode 打印的错误如下:
无效更新:第 0 节中的行数无效。更新后现有节中包含的行数 (1) 必须等于更新前该节中包含的行数 (1),加上或减去从该节插入或删除的行数(0 插入,1 删除)加上或减去移入或移出该节的行数(0 移入,0 移出)。
我已在 Stack 上阅读过此错误,但我无法弄清楚。 :(
提前致谢。
【问题讨论】:
标签: ios swift swift2 tableview