首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >使用trailingSwipeActionsConfigurationForRowAt删除行时出现奇怪的缺少其他行的问题

使用trailingSwipeActionsConfigurationForRowAt删除行时出现奇怪的缺少其他行的问题
EN

Stack Overflow用户
提问于 2019-06-12 21:50:18
回答 2查看 300关注 0票数 0

我正在尝试使用trailingSwipeActionsConfigurationForRowAt函数从UITableView中删除行。

该行将被删除并消失。这部分没问题。

但是,下一行将要出现在屏幕上,或者当我向下滑动与删除的行相同数量的行时,甚至不会加载到tableView上。

(https://poirot.deus4.com/photo_2019-06-12_16-44-01.jpg)

(https://poirot.deus4.com/photo_2019-06-12_16-43-56.jpg)

(https://poirot.deus4.com/photo_2019-06-12_16-43-49.jpg)

(https://poirot.deus4.com/photo_2019-06-12_16-43-38.jpg)

video

代码语言:javascript
复制
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return filteredProducts.count
}

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: .cellID, for: indexPath) as! ProductTableCell

        cell.backgroundColor = .red
        return cell
}

override func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {

        let hide = UIContextualAction(style: .destructive, title: "Hide") { action, view, completion in

            self.filteredProducts.remove(at: indexPath.row)
            tableView.deleteRows(at: [indexPath], with: .automatic)

            completion(true)
        }

        hide.image = #imageLiteral(resourceName: "hdie_product")
        hide.backgroundColor = .midGrey

        let conf = UISwipeActionsConfiguration(actions: [hide])
        return conf
}
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56563828

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档