添加二级评论多个的时候的逻辑,默认每次点击出现5条

This commit is contained in:
2026-01-16 19:29:42 +08:00
parent 7fa124d45f
commit ac0d9584d8
5 changed files with 57 additions and 21 deletions

View File

@@ -319,13 +319,17 @@ static NSString *const kCommentFooterIdentifier = @"CommentFooter";
#pragma mark - Footer Actions
///
static NSInteger const kRepliesLoadCount = 5;
- (void)handleFooterActionForSection:(NSInteger)section {
KBAICommentModel *comment = self.comments[section];
KBAIReplyFooterState state = [comment footerState];
switch (state) {
case KBAIReplyFooterStateExpand: {
[self expandRepliesForSection:section];
case KBAIReplyFooterStateExpand:
case KBAIReplyFooterStateLoadMore: {
[self loadMoreRepliesForSection:section];
break;
}
case KBAIReplyFooterStateCollapse: {
@@ -337,15 +341,17 @@ static NSString *const kCommentFooterIdentifier = @"CommentFooter";
}
}
- (void)expandRepliesForSection:(NSInteger)section {
- (void)loadMoreRepliesForSection:(NSInteger)section {
KBAICommentModel *comment = self.comments[section];
NSInteger currentCount = comment.displayedReplies.count;
//
[comment expandAllReplies];
//
[comment loadMoreReplies:kRepliesLoadCount];
//
//
NSInteger newCount = comment.displayedReplies.count;
NSMutableArray *insertIndexPaths = [NSMutableArray array];
for (NSInteger i = 0; i < comment.displayedReplies.count; i++) {
for (NSInteger i = currentCount; i < newCount; i++) {
[insertIndexPaths addObject:[NSIndexPath indexPathForRow:i inSection:section]];
}