如何实现“滑动删除”列表中的项
1个回答
展开全部
// Override to support editing the table view.左滑删除
func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
print("delete table view cell")
if editingStyle == .Delete {
//获取数组中要删除的数据
let this_password = self.todos[indexPath.row]
this_password.delete { (result) in
if(result.isSuccess){
// 根据 result.isSuccess 可以判断是否删除成功
self.todos.removeAtIndex(indexPath.row)
//删除对应的cell
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
print("delete table view cell")
if editingStyle == .Delete {
//获取数组中要删除的数据
let this_password = self.todos[indexPath.row]
this_password.delete { (result) in
if(result.isSuccess){
// 根据 result.isSuccess 可以判断是否删除成功
self.todos.removeAtIndex(indexPath.row)
//删除对应的cell
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询