处理一级评论cell头像闪的问题
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user