Add swipe to delete UITableViewCell

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

    func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]?
    {
    
        let delete = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: "DELETE"){(UITableViewRowAction,NSIndexPath) -> Void in
    
            print("What u want while Pressed delete")
        }
        let edit = UITableViewRowAction(style: UITableViewRowActionStyle.Normal, title: "EDIT"){(UITableViewRowAction,NSIndexPath) -> Void in
    
            print("What u want while Pressed Edit")
        }
    
        edit.backgroundColor = UIColor.blackColor()
        return [delete,edit]
    }
    

提交回复
热议问题