I understand that UITableView will call -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath method to get each of the cells for the table view. Say I have my data source is fetched over the internet and I have to account for latency. What will be the best way of “stopping” this method from being called? Should it block on a boolean flag in the application? Should I just call cellForRowAtIndexPath again from within my application?
I am uncertain as to when the function gets called, ie, how often the UITableView “refreshes” itself. Any explanations will be helpful! Thanks!
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 innumberOfRowsInSection:.In other words, don’t report any new cells in
numberOfRowsInSection:, until you actually have that data in hand, and thencellForRowAtIndexPath:won’t be called prematurely.When you do get the additional row data, then call
reloadDatato get the UITableView to ask for the number of rows and then callcellForRowAtIndex:.