views:

34

answers:

0

I want to display a table which has multiple sections and initally only 3 elements of sections are shown. When user taps the section footer, section footer gets lost (becomes nil) and all elements of that section will be shown to user.

For this reason, when the user taps the section footer, I call below code:

-(void)loadMoreRowsInSection:(NSInteger)section {
    [groupStates replaceObjectAtIndex:section withObject:[NSNumber numberWithBool:YES]];
    [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:section] withRowAnimation:NO];
}

I have the following code to show section footer or not:

-(UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    int count = [[(NSDictionary*)[filters objectAtIndex:section] valueForKeyPath:@"values.value"] count];
    if (count>3&&![[groupStates objectAtIndex:section] boolValue]) {
        LoadMoreFooter* loadMoreFooter = [[LoadMoreFooter alloc] initWithParent:self Section:section];
        return [loadMoreFooter view];
    }   
    else return nil;
}

When user taps the section footer and loadMoreRowsInSection function is called, this section is reloaded but the current rows of that section disappear. When I scroll up down, making the rows go out of the screen and in again, rows appear again.

If I call reloadData instead of reloadSections:withRowAnimation:, there is no problem but it does not seem to be a good idea to reload all the table. Plus there is no animation in reloadTable.

Has anyone encountered this problem?