How to reload a table in a separate section

I have 56 partitions in my table view, and I save the number of the partition that is currently selected in an integer variable called "activeTimeSlot". How to use the method below to reload the partition that is currently selected. I do it like

 [self.tblView reloadSections:[NSIndexSet indexSetWithIndex:activeTimeSlot] withRowAnimation:UITableViewRowAnimationAutomatic];

but I noticed that in this way the datasource method is called below for a table view for all sections, i.e. reloading the entire partition.

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

I am not sure how to use NSIndexSet and how to use NSIndexSet to reload more than 1 partition.

+5
source share
2 answers

As I saw from your comments, you are checking the method call

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

, . . , , , .

NSLog(@"Section %d", indexPath.section);

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

, .

PS: : .

+3

, .

NSMutableIndexSet *indetsetToUpdate = [[NSMutableIndexSet alloc]init];

[indetsetToUpdate addIndex:previousSection]; // [indetsetToUpdate addIndex:<#(NSUInteger)#>] 
// You can add multiple indexes(sections) here.

[detailTableView reloadSections:indetsetToUpdate withRowAnimation:UITableViewRowAnimationFade];

, .

, .

+8

All Articles