如何使用领域之间的桌子部分之间移动单元格?
在我的项目中,我将使用两个部分使用TableView。我需要使用方法-MOVERAT在一个部分或部分之间移动单元格。然后我用领域写。
在我的代码单元中,在各节之间移动,但在一个部分中,我无法交换它们。
override func tableView(\_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) {
let task = sourceIndexPath.section == 0 ? importantTask[sourceIndexPath.row] : currentTask[sourceIndexPath.row] //choose from which section the task will be taken
let type = destinationIndexPath.section == 0 ? TaskPriority.important : TaskPriority.normal // change the type of the task (it depends in which section the task will be located)
let realm = try! Realm()
try! realm.write {
task.type = type // change task type to new type
}
tableView.reloadData()
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论