From 7fa124d45f73fec9f834c73c584024e9e29833be Mon Sep 17 00:00:00 2001 From: CodeST <694468528@qq.com> Date: Fri, 16 Jan 2026 19:13:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E4=B8=80=E7=BA=A7=E8=AF=84?= =?UTF-8?q?=E8=AE=BAcell=E5=A4=B4=E5=83=8F=E9=97=AA=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- keyBoard/Class/AiTalk/V/KBAICommentView.m | 51 ++++++++++++++++++----- 1 file changed, 41 insertions(+), 10 deletions(-) diff --git a/keyBoard/Class/AiTalk/V/KBAICommentView.m b/keyBoard/Class/AiTalk/V/KBAICommentView.m index c8b25ad..6acdf67 100644 --- a/keyBoard/Class/AiTalk/V/KBAICommentView.m +++ b/keyBoard/Class/AiTalk/V/KBAICommentView.m @@ -343,24 +343,55 @@ static NSString *const kCommentFooterIdentifier = @"CommentFooter"; // 一次性展开全部回复 [comment expandAllReplies]; - // 直接刷新该 section -// [UIView performWithoutAnimation:^{ - [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:section] - withRowAnimation:UITableViewRowAnimationAutomatic]; -// }]; + // 计算要插入的行 + NSMutableArray *insertIndexPaths = [NSMutableArray array]; + for (NSInteger i = 0; i < comment.displayedReplies.count; i++) { + [insertIndexPaths addObject:[NSIndexPath indexPathForRow:i inSection:section]]; + } + + // 插入行(不刷新 Header,避免头像闪烁) + [self.tableView beginUpdates]; + if (insertIndexPaths.count > 0) { + [self.tableView insertRowsAtIndexPaths:insertIndexPaths + withRowAnimation:UITableViewRowAnimationAutomatic]; + } + [self.tableView endUpdates]; + + // 手动刷新 Footer + KBAICommentFooterView *footerView = + (KBAICommentFooterView *)[self.tableView footerViewForSection:section]; + if (footerView) { + [footerView configureWithComment:comment]; + } } - (void)collapseRepliesForSection:(NSInteger)section { KBAICommentModel *comment = self.comments[section]; + NSInteger rowCount = comment.displayedReplies.count; + + // 计算要删除的行 + NSMutableArray *deleteIndexPaths = [NSMutableArray array]; + for (NSInteger i = 0; i < rowCount; i++) { + [deleteIndexPaths addObject:[NSIndexPath indexPathForRow:i inSection:section]]; + } // 收起全部回复 [comment collapseReplies]; - // 直接刷新该 section -// [UIView performWithoutAnimation:^{ - [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:section] - withRowAnimation:UITableViewRowAnimationAutomatic]; -// }]; + // 删除行(不刷新 Header,避免头像闪烁) + [self.tableView beginUpdates]; + if (deleteIndexPaths.count > 0) { + [self.tableView deleteRowsAtIndexPaths:deleteIndexPaths + withRowAnimation:UITableViewRowAnimationAutomatic]; + } + [self.tableView endUpdates]; + + // 手动刷新 Footer + KBAICommentFooterView *footerView = + (KBAICommentFooterView *)[self.tableView footerViewForSection:section]; + if (footerView) { + [footerView configureWithComment:comment]; + } } #pragma mark - Actions