有什么方法可以让我只重新加载 tableViewCell 而不是重新加载 tableView section title View ?当我切换 UITableViewCell 时我想更新数据重新加载更改
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
switch self[selectedIndex] {
case .tracks:
let cell = tableView.dequeueReusableCell(withIdentifier: cellId, for: indexPath) as! TracksCell
return cell
case .playlists:
let cell = tableView.dequeueReusableCell(withIdentifier: cellPlayListId, for: indexPath) as! PlaylistCell
return cell
}
我只想重新加载 UITableViewCell,我不想重新加载下面的代码
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {}
如果我使用 tableView.reload() 它将影响我在 viewForHeaderInSection 中的样式因为我已经添加了 UIViewScroll
谢谢你的帮助!
最佳答案
如果你只想重新加载特定的 tableView 单元格,那么使用这个:
tableView.reloadRows(at: [IndexPath(row: rowNumber, section: 0)], with: .automatic)
它只重新加载单元格而不是部分。
关于ios - 如何仅在 swift 中重新加载 tableViewCell?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43567995/