crash on deleteRowsAtIndexPaths

前端 未结 5 548
温柔的废话
温柔的废话 2020-11-30 12:46

My application crashes when I\'m deleting row from table. Here is my sources where the bug is detected and stack trace. Thanx!

//delete row from database
- (         


        
5条回答
  •  离开以前
    2020-11-30 13:03

    Updated Swift 4.2

    If you are about to remove last row in section, you should remove entire section instead of row. To do that:

        tableView.beginUpdates()
        dataArray.remove(at: row)
        if tableView.numberOfRows(inSection: section) == 1 {
            tableView.deleteSections(IndexSet(integer: section), with: .automatic)
        }
        else {
            tableView.deleteRows(at: indexPath, with: .fade)
        }
        tableView.endUpdates()
    

提交回复
热议问题