且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

重新加载后,UITableView分组的节页脚未更新

更新时间:2022-12-06 13:51:08

要向节中添加新行,您必须使用insertRowsAtIndexPaths而不是仅向数据源中添加新对象并重新加载节.

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.

代码如下:

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];