UITableView grouped section footer not updating after reload

前端 未结 2 1084
旧巷少年郎
旧巷少年郎 2021-01-28 06:33

I have 3 or 2 sections (depending on datasource), in my grouped UITableView. I am trying to reload the last section via:

dispatch_async(dispatch_get_main_queue()         


        
2条回答
  •  终归单人心
    2021-01-28 07:06

    In order to add new rows to a section, you must use the insertRowsAtIndexPaths rather than just adding new objects to data source and reloading a section.

    Here's the code:

    NSMutableArray *newCommentsIndexPath = [[NSMutableArray alloc] init];
    
                    for (NSInteger i = currentCount; i < (_postDetailDatasource.commentsFeedInfo.allCommentsArray.count + serverComments.count); i ++)
                    {
                        NSIndexPath *idxPath = [NSIndexPath indexPathForRow:i inSection:sectionNumber];
    
                        [newCommentsIndexPath addObject:idxPath];
                    }
    
                    [_postDetailDatasource.commentsFeedInfo.allCommentsArray addObjectsFromArray:serverComments];
    
                    [feedDetailTB beginUpdates];
    
                    [feedDetailTB insertRowsAtIndexPaths:newCommentsIndexPath withRowAnimation:UITableViewRowAnimationFade];
    
                    [feedDetailTB endUpdates];
    

提交回复
热议问题