Add swipe to delete UITableViewCell

后端 未结 25 1642
暖寄归人
暖寄归人 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:13

    As of Xcode 6.1.1, there are some tiny changes to Dash's answer.

    override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
            return true
        }
    
        override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
            if (editingStyle == UITableViewCellEditingStyle.Delete) {
                // handle delete (by removing the data from your array and updating the tableview)
            }
        }
    

提交回复
热议问题