- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
This video demonstrates the issue I'm visually having.
每隔一段时间,我将这个 block 称为:
self.tableView.beginUpdates()
self.tableView.insertRows(at: [indexPath], with: rowAnimation)
self.tableView.endUpdates()
self.tableView.scrollToRow(at: indexPath, at: scrollPosition, animated: true)
self.tableView.reloadRows(at: [indexPath], with: .automatic)
让我们不要过多地询问它(insertRows 调用和立即的 reloadRows 调用)。这是解决 SlackTextViewController 中错误的建议解决方案。 The bug in question for those curious.
现在,在别处,我调用:
self.tableView.reloadRows(at: [indexPath], with: .automatic)
当我们在两种情况下处理相同的 indexPath 时,如果这两个 block 运行得太快,您会遇到闪烁。
我会发现通过使用 dispatchQueue( :asyncAfter)
方法。
我该如何处理?
更新:目前,我已经通过使用 dispatchQueue(:asyncAfter)
方法修复了这个问题,避免了竞争条件。不过,我想避免这种情况,所以我会在搜索其他答案时继续这样做。
最佳答案
根据您的评论,如果第二次调用发生在网络调用之后的完成 block 中,我猜您正在使用网络调用的结果。如果是这种情况,如果您需要在单元格中反射(reflect)的更改不影响单元格的高度,您可以在索引路径处获取单元格,检查它是否为零(以防用户将其滚动到屏幕外)如果单元格仍然可见,则直接应用更改。无需重新加载。
关于ios - 如果在另一个表更新后调用得太快,tableView.reloadRows 会闪烁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40776862/
当文本扩展 100 个字符时,我的 commentCell 中会出现一个更多按钮。当我按下它时,单元格应将行数限制为 0 并重新加载单元格。 问题是我必须按两次单元格才能放大,两次才能最小化单元格。
当我调用这段代码时: tableView.reloadRows(at: [IndexPath(item: index, section: 0)], with: .none) tableView(_ t
我在右侧滑动时切换 UITableViewCell 上的背景图像。问题是如果我添加 [taskManager reloadRowsAtIndexPaths:@[indexPath] withRowAn
我在我的一个应用程序中使用UITableView。在 tableview 的行内,我有水平滚动 UICollectionView。每当用户双击 Collection View 的单元格时,它会将事件发
我有一个从 CoreData 数据库更新的 TableView ( Controller :MetricsViewController)。我使用了原型(prototype)单元格 (MetricsVi
我创建了这个函数来在点击按钮后重新加载 tableView 的单行。 @IBAction func reloadCell(_ sender: UIButton) { let index = I
要求; 我有一个静态的UITableView,我试图在单击其中一个单元格时打开一个pickerview。我使用 heightForRowAt 更改大小,因此当单击 cell 时,我需要重新加载 以便更
This video demonstrates the issue I'm visually having. 每隔一段时间,我将这个 block 称为: self.tableView.beginUpd
为什么函数 heightForRowAt 总是找到包含行高的数组,该数组最初设置为 nil,即使在重新加载行后仍然为零。 override func tableView(_ tableView
我有一个包含 3 行的表格,每行带有复选按钮。我正在做的是,当我选择所有三个按钮时,我想单击我的取消按钮,该按钮位于 View 中,而不是同一 Controller 上的表格,以重新加载所有 3 行调
我正在尝试弄清楚 Fabric 中的一个错误: Invalid update: invalid number of rows in section 0. The number of rows cont
之前调用 tableView.reloadRows(at: , with: ) 时,tableView.setContentOffset(,animated: ) 似乎无法正常工作。 如果调用了rel
我正在寻找具有 RowAnimation 类型 'bottom' 的延迟行动画,并具有将行推送到 TableView 的特定持续时间。 到目前为止,我找到了两个选项: 在UIView.transiti
我创建了一个包含多个部分的 UITableView,其中包含两个具有动态单元格高度的单元格。在第二个单元格上添加了一个按钮。单击按钮通过更改约束高度来增加第二个单元格的高度。连接到按钮的操作方法是:
这个问题在这里已经有了答案: TableView reloadData vs. beginUpdates & endUpdates (3 个答案) 关闭 5 年前。 tableView.reload
我是一名优秀的程序员,十分优秀!