gpt4 book ai didi

UITableViewRowAction : Delete

转载 作者:可可西里 更新时间:2023-11-01 00:37:35 30 4
gpt4 key购买 nike

我想让用户能够在我执行删除滑动操作时删除表格单元格,但我不知道如何实际删除所选单元格!如您所知,我正在使用 Swift 和 Xcode 6.3.1 编程

var deleteAction = UITableViewRowAction(style: .Default, title: "Delete") { (action, indexPath) -> Void in
tableView.editing = false
println("deleteAction")
}

这也是 Dropbox 的屏幕截图:Screenshot Of Delete Swipe Action

最佳答案

如果你想从 tableView 中完全删除一个单元格,那么你也必须将它从你的表数组中删除。考虑以下代码:

var deleteAction = UITableViewRowAction(style: .Default, title: "Delete") { (action, indexPath) -> Void in
tableView.editing = true
// Remove it from your TableArray and If it is stored into any local storage then you have to remove it from there too because if you doesn't remove it from your local storage then when you reload your tableview it will appears back

self.tableData.removeAtIndex(indexPath.row)

tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Automatic)

}

return [deleteAction]
}

关于UITableViewRowAction : Delete,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30681559/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com