NSInternalInconsistencyException tableView row deletion

后端 未结 1 1316
挽巷
挽巷 2020-12-22 12:43

Swift 3.0 iOS 10.x

Using this code to try and delete a row in a table...

override func tableView(_ tableView: UITableView, commit editingStyle: UITab         


        
相关标签:
1条回答
  • 2020-12-22 13:16

    You must delete row in your data array before deleting in tableView

    override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
        if editingStyle == UITableViewCellEditingStyle.delete {
            print("DELETE \(indexPath)")
            yourArray.remove(at: indexPath.row) /* delete in data array */
            self.tableView.deleteRows(at: [indexPath], with: UITableViewRowAnimation.automatic)
        }
    }
    
    0 讨论(0)
提交回复
热议问题