我想知道是否可以通过简单的方式重新加载tableView而不重新加载第一个单元格/行?如果是这样,您将如何做?
let itemArray:[Int] = []
for i in 1..<itemArray.count {
let indexPath = IndexPath(item: i, section: 0)
tableView.reloadRows(at: [indexPath], with: .fade)
}
如果您的表格当前未分组,最好的方法是将第一个单元格添加到一个部分,将所有其他单元格添加到另一部分。然后,您可以使用
轻松地重新加载除第一个单元格以外的所有单元格 //section 0 - your 1st cell
//section 1 - other cells
tableView.reloadSections([1], with: .none)
只需使用reloadRows方法即可重新加载tableView。
var dataSource: [SomeData] = []
func reloadAllButFirstRow() {
guard dataSource.count > 0 else { return }
tableView.reloadRows(
at: (1...dataSource.count).map { IndexPath(row: $0, section: 0) },
with: .fade
)
}