且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在加载数据之前停止加载UITableView?

更新时间:2023-12-05 17:24:28

如果您没有数据,或者您没有其他单元格的数据,那么 cellForRowAtIndex:。该值设置在 numberOfRowsInSection:

If you don't have data, or you don't have the data for additional cells, then cellForRowAtIndex: will not be called as long as you don't tell the UTableView that you have rowCounts or new rowCounts. That value is being set in numberOfRowsInSection:.

换句话说,不报告 numberOfRowsInSection:,直到你实际拥有该数据为止,然后 cellForRowAtIndexPath:将不会过早被调用。

In other words, don't report any new cells in numberOfRowsInSection:, until you actually have that data in hand, and then cellForRowAtIndexPath: won't be called prematurely.

当你获得额外的行数据时,然后调用 reloadData 来让UITableView询问行数和然后调用 cellForRowAtIndex:

When you do get the additional row data, then call reloadData to get the UITableView to ask for the number of rows and then call cellForRowAtIndex:.