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?
|
1 answer
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
- Can you please explain more specifically the logic of how to use your method of adding cells? - user204104
- And links from Google will not work? stackoverflow.com/questions/22482323/… stackoverflow.com/questions/20987585/… With the optimization, I think everything is clear? - Valentine
- gist.github.com/dotprox/74b0bf4af7a5b7255a8114dbca1ec5f5 I do not fully understand how to work with these methods, so while I understand, typing this code, I get an error - the number of lines before the update should be equal to the number after the update - user204104
- and you in numberOfRowsInSection already new quantity comes back? stackoverflow.com/questions/14060777/… - Valentine
- After the beginLoading internals are executed, the presenter sends new data to the controller, updating the questions array, which I pass to the dataSource - user204104
|
viewDidLoadmethod, 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 methodcellForRowcells 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 methodreloadDataat the table - user204104