Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ios: [tableView reloadData] [closed]

Tags:

ios

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];
like image 490
Dev Avatar asked Oct 04 '12 11:10

Dev


2 Answers

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.

like image 158
Eiko Avatar answered Oct 11 '22 03:10

Eiko


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.

like image 34
Fogmeister Avatar answered Oct 11 '22 03:10

Fogmeister