ios - 如何仅在 swift 中重新加载 tableViewCell?

标签 ios swift uitableview

有什么方法可以让我只重新加载 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/

相关文章:

objective-c - 在表格 View 中制作淡入淡出的标题,就像在笔记应用程序中一样

android - 自动在 Play Store 或 App Store 中搜索应用程序

ios - 在 Swift 中将 Parse GeoPoint 转换为 CLLocation

ios - 组合数组中的元素

ios - += 和 append 将单个项目添加到数组的区别?

ios - 如何修复 UITableView 中的重复搜索结果

ios - 在子类中将打开的方法标记为 final

iphone - 应用程序处于前台模式时如何禁用 iPhone/iPad 自动锁定?

swift - Swift 中的 macOS notify_keys.h 常量

ios - UITableViewCell,显示没有滑动的滑动式删除按钮