如何仅在 swift 中重新加载 tableViewCell? [英] How to reload tableViewCell only in swift?

查看:25
本文介绍了如何仅在 swift 中重新加载 tableViewCell?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么办法可以只重新加载 tableViewCell 但不要让它重新加载 tableView 部分标题 View ?当我切换 UITableViewCell 时,我想更新数据重新加载更改

Is there any way that I could reload only tableViewCell only but don't make it reload tableView section title View ? when I switched UITableViewCell I want to update data reload change

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 我不想重新加载下面的代码

What I want to do is just reload UITableViewCell only I don't want to reload this code below

 override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {} 

如果我使用 tableView.reload() 它会影响我在 viewForHeaderInSection 中的样式因为我添加了 UIViewScroll

if I use tableView.reload() it will effected my style in viewForHeaderInSection Because I have added UIViewScroll

感谢您的帮助!

推荐答案

如果您只想重新加载特定的 tableView 单元格,请使用:

If you want to reload only particular tableView cell then use this:

tableView.reloadRows(at: [IndexPath(row: rowNumber, section: 0)], with: .automatic)

它只重新加载单元格而不是部分.

It reload only cell not the section.

这篇关于如何仅在 swift 中重新加载 tableViewCell?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆