ios - 如何异步更新 UITableView?

标签 ios uitableview

如果一个 UITableView 的数据源数组需要异步更新,例如,它的成员被通过网络不断接收的数据删除和追加,那么我们如何更新 UITableView 并插入和删除相应的元素行?

最佳答案

好吧,tableView.reloadData() 将始终刷新整个 TableView 。因此,如果数据来自网络,您始终可以调整数据源,然后调用 tableView.reloadData()

您还可以将 tableView.beginUpdates() + tableView.endUpdates() 与相应的插入、删除、移动调用一起使用(参见 Apple Documentation),但这些通常是用于动画变化。 - 您必须先更新数据源并知道您尝试更改的索引路径。

关于ios - 如何异步更新 UITableView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50492066/

相关文章:

ios - 架构 i386 : "_OBJC_CLASS_$_ZipException", 的 undefined symbol 引用自:错误

ios - Objective C 中的属性(为自己读写,为他人只读)

ios - 在嵌套闭包中声明 weak

ios - 更改 ViewController 时如何保持 UISlider 状态? ( swift )

ios - 无法在 Storyboard中的 UITableView 上方添加 UIView

iphone - 折叠和隐藏 UITableview 的静态 UITableViewCells

ios - UISplitViewController 的 preferredDisplayMode : incorrect behavior

ios - 在 UITableView 中, "visibleCells"的代表是什么?

objective-c - UITextView 上的 UITableViewCell 选择

ios - popoverPresentationController 从 iPhone 上的 UITableViewController 模态显示