Is [tableView reloadData]
affects perfomance in ios? What is [tableView reloadData]
? How it is reloading the tableview? Is there any other way to reload tableview?
I want to add some rows to the end of the tableview. How can i do this?
What is the difference between
[self.tableView reloadData]
and
[self.tableView beginUpdates];
[self.tableView insertRowsAtIndexPaths:insertIndexPathswithRowAnimation:UITableViewRowAnimationAutomatic];
[self.tableView endUpdates];
reloadData does just that - a complete update of the (visible part of the) table view.
If you just need to update certain cells, i.e. update, insert, remove or move, use the appropriate update methods instead. This will even animate the changes.
AFAIK, [self.tableView reloadData] is used more for if your data has changed completely and you want to display the latest version (or maybe the filter has changed etc...)
i.e. Imagine you have a table showing football players and you "flick a switch" to show football players from a different team. In this case you would tend to use reloadData. This will then refresh the entire table.
[self.tableView beginUpdates];
[self.tableView insertRowsAtIndexPaths:insertIndexPathswithRowAnimation:UITableViewRowAnimationAutomatic];
[self.tableView endUpdates];
is used for adding new data into a current set of data that is shown. This will not refresh the entire but will animate the new row into the current table.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With