Reputation: 496
I have found 2 functions to reload my rows of UITableView
1st.
[tableView reloadRowsAtIndexPaths:[tableView indexPathsForVisibleRows]
withRowAnimation:UITableViewRowAnimationNone];
2nd.
[tableView reloadData];
What is more specific way to reload UITableView Data
Upvotes: 0
Views: 1676
Reputation: 27072
This answer may have two cases,
a) You've the table with at least a single section (with a title or returning a view for section)
reloadData
then it'll also reload section too. But reloadRowsAtIndexPaths:withRowAnimation:
will only reload the visible cells and not the section.b) You've the table with at least a single section (without a title or returning a view for section)
reloadData
or reloadRowsAtIndexPaths:withRowAnimation:
both will reload only the visible cells.So which one is the better?
reloadRowsAtIndexPaths:withRowAnimation:
method. Or if you want to reload cells along with section then should call reloadData
method.Upvotes: 1
Reputation: 52535
Both are "reliable" and possibly "specific" (depending on what you mean by specific) -- in fact, there are even more ways:
reloadData
reloadRowsAtIndexPaths:withRowAnimation:
reloadSections:withRowAnimation:
reloadSectionIndexTitles
Check the developer documentation (https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITableView_Class/index.html) on the differences, but the short answer is that they are all reliable -- it just depends on how much information you want to reload, and if you want to do it with animation.
For example, if you only want to reload certain rows, you can use reloadRowsAtIndexPaths:withRowAnimation:
. If you want to reload a whole section, use reloadSections:withRowAnimation:
.
Upvotes: 1