Add swipe to delete UITableViewCell

后端 未结 25 1641
暖寄归人
暖寄归人 2020-11-30 17:50

I am making a CheckList application with a UITableView. I was wondering how to add a swipe to delete a UITableViewCell.

This is my ViewCont

25条回答
  •  忘掉有多难
    2020-11-30 18:33

    swift 3

    func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
    
        return true
    }
    
    func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
    
        if (editingStyle == UITableViewCellEditingStyle.delete) {
    
            arrayCityName.remove(at: indexPath.row)
            self.tableCityName.reloadData()
        }
    }
    

提交回复
热议问题