处理一级评论cell头像闪的问题

This commit is contained in:
2026-01-16 19:13:26 +08:00
parent 3dfb8f31e2
commit 7fa124d45f

View File

@@ -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