隐藏无更多消息文案
This commit is contained in:
@@ -176,6 +176,7 @@ static NSString *const kCommentFooterIdentifier = @"CommentFooter";
|
|||||||
- (void)loadComments {
|
- (void)loadComments {
|
||||||
if (self.companionId <= 0) {
|
if (self.companionId <= 0) {
|
||||||
NSLog(@"[KBAICommentView] companionId 未设置,无法加载评论");
|
NSLog(@"[KBAICommentView] companionId 未设置,无法加载评论");
|
||||||
|
[self showEmptyState];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,6 +192,10 @@ static NSString *const kCommentFooterIdentifier = @"CommentFooter";
|
|||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
NSLog(@"[KBAICommentView] 加载评论失败:%@", error.localizedDescription);
|
NSLog(@"[KBAICommentView] 加载评论失败:%@", error.localizedDescription);
|
||||||
|
// 加载失败也显示空态
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
[strongSelf showEmptyStateWithError];
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,6 +209,8 @@ static NSString *const kCommentFooterIdentifier = @"CommentFooter";
|
|||||||
- (void)updateCommentsWithPageModel:(KBCommentPageModel *)pageModel {
|
- (void)updateCommentsWithPageModel:(KBCommentPageModel *)pageModel {
|
||||||
if (!pageModel) {
|
if (!pageModel) {
|
||||||
NSLog(@"[KBAICommentView] pageModel 为空");
|
NSLog(@"[KBAICommentView] pageModel 为空");
|
||||||
|
// 数据为空,显示空态
|
||||||
|
[self showEmptyState];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,6 +243,49 @@ static NSString *const kCommentFooterIdentifier = @"CommentFooter";
|
|||||||
|
|
||||||
[self updateTitle];
|
[self updateTitle];
|
||||||
[self.tableView reloadData];
|
[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 {
|
- (void)updateTitle {
|
||||||
@@ -592,6 +642,9 @@ static NSInteger const kRepliesLoadCount = 5;
|
|||||||
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
||||||
_tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
|
_tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
|
||||||
|
|
||||||
|
// 关闭空数据占位,避免加载时显示"暂无数据"
|
||||||
|
_tableView.useEmptyDataSet = NO;
|
||||||
|
|
||||||
// 注册 Header/Cell/Footer
|
// 注册 Header/Cell/Footer
|
||||||
[_tableView registerClass:[KBAICommentHeaderView class]
|
[_tableView registerClass:[KBAICommentHeaderView class]
|
||||||
forHeaderFooterViewReuseIdentifier:kCommentHeaderIdentifier];
|
forHeaderFooterViewReuseIdentifier:kCommentHeaderIdentifier];
|
||||||
|
|||||||
@@ -111,6 +111,12 @@ static const NSTimeInterval kTimestampInterval = 5 * 60; // 5 分钟
|
|||||||
[strongSelf.tableView.mj_footer endRefreshing];
|
[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;
|
self.tableView.mj_footer.hidden = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user