I want to reload only one section not the full table. Is there any method in UITableView
.
[tableView reloadData]
is used to load full table.
I want to know how to load only one section, as I have large number of rows in the table.
If you want to reload your table view while also saving and restoring any selections, you should take a copy of the indexPathsForSelectedRows property before the reload, then re-apply those selections after calling reloadData() . With that in place, you can now call yourTableView.
reloadData()Reloads the rows and sections of the table view.
The reloadSections method bugs me -- as I have to construct a few objects. This is great if you need the flexibility, but sometimes I also just want the simplicity too. It goes like this:
NSRange range = NSMakeRange(0, 1); NSIndexSet *section = [NSIndexSet indexSetWithIndexesInRange:range]; [self.tableView reloadSections:section withRowAnimation:UITableViewRowAnimationNone];
This will reload the first section. I prefer to have a category on UITableView and just call this method:
[self.tableView reloadSectionDU:0 withRowAnimation:UITableViewRowAnimationNone];
My category method looks like this:
@implementation UITableView (DUExtensions) - (void) reloadSectionDU:(NSInteger)section withRowAnimation:(UITableViewRowAnimation)rowAnimation { NSRange range = NSMakeRange(section, 1); NSIndexSet *sectionToReload = [NSIndexSet indexSetWithIndexesInRange:range]; [self reloadSections:sectionToReload withRowAnimation:rowAnimation]; }
Yes, there is:
- (void)reloadSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation
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