隐藏无更多消息文案

This commit is contained in:
2026-01-28 15:32:56 +08:00
parent d8d5bdc3ae
commit 22f77d56ea
2 changed files with 59 additions and 0 deletions

View File

@@ -176,6 +176,7 @@ static NSString *const kCommentFooterIdentifier = @"CommentFooter";
- (void)loadComments {
if (self.companionId <= 0) {
NSLog(@"[KBAICommentView] companionId 未设置,无法加载评论");
[self showEmptyState];
return;
}
@@ -191,6 +192,10 @@ static NSString *const kCommentFooterIdentifier = @"CommentFooter";
if (error) {
NSLog(@"[KBAICommentView] 加载评论失败:%@", error.localizedDescription);
//
dispatch_async(dispatch_get_main_queue(), ^{
[strongSelf showEmptyStateWithError];
});
return;
}
@@ -204,6 +209,8 @@ static NSString *const kCommentFooterIdentifier = @"CommentFooter";
- (void)updateCommentsWithPageModel:(KBCommentPageModel *)pageModel {
if (!pageModel) {
NSLog(@"[KBAICommentView] pageModel 为空");
//
[self showEmptyState];
return;
}
@@ -236,6 +243,49 @@ static NSString *const kCommentFooterIdentifier = @"CommentFooter";
[self updateTitle];
[self.tableView reloadData];
//
if (self.comments.count == 0) {
[self showEmptyState];
} else {
[self hideEmptyState];
}
}
///
- (void)showEmptyState {
self.tableView.useEmptyDataSet = YES;
self.tableView.emptyTitleText = @"暂无评论";
self.tableView.emptyDescriptionText = @"快来抢沙发吧~";
self.tableView.emptyImage = nil; //
self.tableView.emptyVerticalOffset = -50; //
[self.tableView kb_reloadEmptyDataSet];
}
///
- (void)showEmptyStateWithError {
self.tableView.useEmptyDataSet = YES;
self.tableView.emptyTitleText = @"加载失败";
self.tableView.emptyDescriptionText = @"点击重新加载";
self.tableView.emptyImage = nil;
self.tableView.emptyVerticalOffset = -50;
//
__weak typeof(self) weakSelf = self;
self.tableView.emptyDidTapView = ^{
__strong typeof(weakSelf) strongSelf = weakSelf;
if (strongSelf) {
[strongSelf loadComments];
}
};
[self.tableView kb_reloadEmptyDataSet];
}
///
- (void)hideEmptyState {
self.tableView.useEmptyDataSet = NO;
[self.tableView kb_reloadEmptyDataSet];
}
- (void)updateTitle {
@@ -592,6 +642,9 @@ static NSInteger const kRepliesLoadCount = 5;
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
// "暂无数据"
_tableView.useEmptyDataSet = NO;
// Header/Cell/Footer
[_tableView registerClass:[KBAICommentHeaderView class]
forHeaderFooterViewReuseIdentifier:kCommentHeaderIdentifier];

View File

@@ -111,6 +111,12 @@ static const NSTimeInterval kTimestampInterval = 5 * 60; // 5 分钟
[strongSelf.tableView.mj_footer endRefreshing];
}
}];
// "已经全部加载完毕"
MJRefreshAutoNormalFooter *footer = (MJRefreshAutoNormalFooter *)self.tableView.mj_footer;
footer.stateLabel.hidden = YES; //
footer.refreshingBlock = footer.refreshingBlock; //
self.tableView.mj_footer.hidden = YES;
}