Having reached the last cell in the table, using the delegate method tableView(tableView:, willDisplayCell:, UITableViewCell:, forRowAtIndexPath:) , I send a message to the presenter, which starts to load data from the server, in the caliber of the presenter method I update the data via tableView.reloadData() , at the moment of triggering the update of the table - the scrolling animation lags. How should update data be organized to avoid this lag?

  • First, how do you fill the cells? - VAndrJ
  • @VAndrJ There are several containers that contain data to fill the cells in the viewDidLoad method, the controller informs the presenter that it has loaded and the presenter starts to return data and fill in empty objects. There are several types of cells, each of which has a delegate method implemented a controller and method cellForRow cells are filled with data from the containers, in the end, all data manipulation are associated with the fact that the controller informs presenters about what that user actions and the latter fills the container, and sweat m pulls method reloadData at the table - user204104
  • and what is the last cell? does this mean that everyone is working, and one is stupid, or the last cell in the sense of there are 10 filled cells, and when it reaches the tenth, the next 10 are loaded together? - Max Mikheyenko 9:32 pm
  • @MaxMikheyenko my last cell is the progressCell, in which I put the activity indicator, the place for the cell with the indicator is allocated, if I am sure that the server has more data for the table, that is, I fill the dataSource containers, and in the numberOfRows method I’ll see if I can I still have something to ship? dataForTable.count + 1: dataForTable.count - user204104 4:02 pm
  • then just do the download on the background thread - Max Mikheyenko

1 answer 1

Try adding cells like this:

[self.tableView beginUpdates]; [self.tableView insertRowsAtIndexPaths:insertIndexPaths withRowAnimation:UITableViewRowAnimationFade]; [self.tableView endUpdates];

Also check that the update is slowing down, and not filling the cells with data. To do this, try to display empty cells. If it helps, optimize cellForRow