swift tableview 侧滑删除

Posted 肆万零叁佰贰拾

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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)

        }

    }

以上是关于swift tableview 侧滑删除的主要内容,如果未能解决你的问题,请参考以下文章