swift tableview 侧滑删除

//返回编辑类型,滑动删除

    func tableView(tableView: UITableView, editingStyleForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCellEditingStyle {

        return UITableViewCellEditingStyle.Delete

    }

    

    //在这里修改删除按钮的文字

    func tableView(tableView: UITableView, titleForDeleteConfirmationButtonForRowAtIndexPath indexPath: NSIndexPath) -> String? {

        return "点击删除"

    }

    

    //点击删除按钮的响应方法,在这里处理删除的逻辑

    func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {

        if editingStyle == UITableViewCellEditingStyle.Delete {

            

                        self.dataList!.removeAtIndex(indexPath.row)

                        self.tableView!.deleteRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Fade)

        }

    }

posted @ 2017-04-18 12:54  肆万零叁佰贰拾  阅读(3507)  评论(0编辑  收藏  举报