iphone - 如何使用iphone tableView的reloadData方法

标签 iphone uitableview

我有一个 UITableViewController 类。我正在使用 NSMutableArray 来填充表格单元格。我正在从数据库获取数据并将其添加到数组中。但细胞显示的是旧结果。如何使用 reladData 方法以及我应该在 UITableViewController 中的何处调用此方法?

最佳答案

我引用苹果的文档何时不使用它:

The table view's delegate or data source calls this method when it wants the table view to completely reload its data. It should not be called in the methods that insert or delete rows, especially within an animation block implemented with calls to beginUpdates and endUpdates.

因此,当您更改模型但不使用 tableview 方法来更改表时调用它,例如:

deleteRowsAtIndexPaths:withRowAnimation:
deleteSections:withRowAnimation:
insertRowsAtIndexPaths:withRowAnimation:
insertSections:withRowAnimation:

关于iphone - 如何使用iphone tableView的reloadData方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5598893/

相关文章:

ios - UIStepper 没有更新相应的标签

swift - 准备函数不通过segue调用

Iphone : How to scroll to the 1st cell of the 2nd section, 让第一部分的标题可见

iphone - Swift 根据屏幕尺寸为元素赋予高度

iphone - .pch 中的 Xcode 编译错误? (iOS)

iphone - 如何使用 +fontWithName :size: and specify both the font family name and the specific style information for the font? 创建字体

ios - UITableView 与 SKSTableViewCell 选择问题

iphone - 任何人都知道绘制思维导图/visio/gra 等图表的 iOS 库或示例

iphone - 如何知道一个数字是否大于iphone objective-c中的最大值

ios - 在 UITableView 中水平滚动 - Swift 3, iOS