我使用的方法是用户可以选择删除除其他对象之外的对象。当我单击“删除”时,出现以下错误:
原因:'UITableView内部错误:无法生成旧部分计数:1和新部分计数:0的新部分图'
这是我的代码:
func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? {
let position = UITableViewRowAction(style: UITableViewRowActionStyle.Normal, title: "Posição", handler: { (action: UITableViewRowAction, indexPath: NSIndexPath) -> Void in
tableView.editing = false
})
let remove = UITableViewRowAction(style: UITableViewRowActionStyle.Destructive, title: "Remover", handler: { (action: UITableViewRowAction, indexPath: NSIndexPath) -> Void in
self.tableData.removeObjectAtIndex(indexPath.row)
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Automatic)
})
return [remove, position]
}
我确实需要使用 editActionsForRowAtIndexPath 方法
最佳答案
您需要先从表数据源中删除该对象。
试试这个
tableView.beginUpdates()
self.tableData.removeObjectAtIndex(indexPath.row)
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Automatic)
tableView.endUpdates()
关于ios - 尝试删除表行时出错 : UITableView internal bug,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33306591/