处理一级评论cell头像闪的问题
This commit is contained in:
@@ -343,24 +343,55 @@ static NSString *const kCommentFooterIdentifier = @"CommentFooter";
|
|||||||
// 一次性展开全部回复
|
// 一次性展开全部回复
|
||||||
[comment expandAllReplies];
|
[comment expandAllReplies];
|
||||||
|
|
||||||
// 直接刷新该 section
|
// 计算要插入的行
|
||||||
// [UIView performWithoutAnimation:^{
|
NSMutableArray *insertIndexPaths = [NSMutableArray array];
|
||||||
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:section]
|
for (NSInteger i = 0; i < comment.displayedReplies.count; i++) {
|
||||||
withRowAnimation:UITableViewRowAnimationAutomatic];
|
[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 {
|
- (void)collapseRepliesForSection:(NSInteger)section {
|
||||||
KBAICommentModel *comment = self.comments[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];
|
[comment collapseReplies];
|
||||||
|
|
||||||
// 直接刷新该 section
|
// 删除行(不刷新 Header,避免头像闪烁)
|
||||||
// [UIView performWithoutAnimation:^{
|
[self.tableView beginUpdates];
|
||||||
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:section]
|
if (deleteIndexPaths.count > 0) {
|
||||||
withRowAnimation:UITableViewRowAnimationAutomatic];
|
[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
|
#pragma mark - Actions
|
||||||
|
|||||||
Reference in New Issue
Block a user