ios - 重新排列表格视图单元格时出现问题
问题描述
我正在制作像 Image Gallery 这样的应用程序。当然,它有 2 个部分。我的意思是 activeImageGalleries 和 recentDeletedImageGalleries
我的表格视图单元格可以重新排列,但我希望它只是重新排列它的部分,而不是其他部分..但它不起作用
这是我的代码:
@IBAction func onEditing(_ sender: Any) {
tableView.isEditing = !tableView.isEditing
}
override func tableView(_ tableView: UITableView, moveRowAt fromIndexPath: IndexPath, to: IndexPath) {
if fromIndexPath.section != to.section {
return
}
if fromIndexPath.section == 0 {
let sourceImageGallery = activeImageGalleries.remove(at: fromIndexPath.row)
activeImageGalleries.insert(sourceImageGallery, at: to.row)
}else {
let sourceImageGallery = recentlyDeletedImageGalleries.remove(at: fromIndexPath.row)
recentlyDeletedImageGalleries.insert(sourceImageGallery, at: to.row)
}
}
有人知道如何解决吗?
解决方案
推荐阅读
- python - Nginx:Linux 服务器上的内部端口转发
- sql - 如何优化结合了 INNER JOIN、DISTINCT 和 WHERE 的 SQL 查询?
- python - 为什么整数可以存储十六进制值但不能存储相同的十进制值?
- r - 如何使用 R 从 ECMWF 数据存档中下载 ERA-Interim 数据?
- php - 通过 PHP MYSQL 创建循环 JSON 不使用不同的查询
- javascript - 如何强制更改选项
- hdfs - NiFi moveHDFS 处理器似乎什么都不做
- android - 将图像从 url 加载到 recyclerview,无需 3rd 方库
- reactjs - react-router 将 const 转换为带有子路由的类
- python - 如何检索`__all__`的值