修复聊天最后一条跑到最上面的问题

This commit is contained in:
2026-01-29 13:13:42 +08:00
parent ef52cd4872
commit 4392296616
3 changed files with 126 additions and 59 deletions

View File

@@ -451,7 +451,7 @@
#pragma mark - Private
- (void)updateChatViewBottomInset {
// 2 bottomInset VoiceInputBar
// bottomInset VoiceInputBar
CGFloat bottomInset;
if (self.currentKeyboardHeight > 0.0) {
@@ -468,13 +468,13 @@
bottomInset = (self.currentKeyboardHeight + self.voiceInputBarHeight) - chatViewPhysicalBottomSpace;
//
bottomInset = MAX(bottomInset, 20);
bottomInset = MAX(bottomInset, 0);
NSLog(@"[KBAIHomeVC] 键盘弹起 - bottomInset: %.2f (键盘: %.2f + InputBar: %.2f - 已避开: %.2f)",
bottomInset, self.currentKeyboardHeight, self.voiceInputBarHeight, chatViewPhysicalBottomSpace);
} else {
// bottomInset
bottomInset = 20; //
// bottomInset
bottomInset = 0;
NSLog(@"[KBAIHomeVC] 键盘隐藏 - bottomInset: %.2f", bottomInset);
}
@@ -486,21 +486,11 @@
//
if (self.currentKeyboardHeight > 0.0) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[cell.chatView scrollToBottom]; // 使
[cell.chatView scrollToBottom];
});
}
}
}
NSLog(@"[KBAIHomeVC] 更新 ChatView bottomInset: %.2f (键盘高度: %.2f)", bottomInset, self.currentKeyboardHeight);
for (NSIndexPath *indexPath in self.collectionView.indexPathsForVisibleItems) {
KBPersonaChatCell *cell = (KBPersonaChatCell *)[self.collectionView cellForItemAtIndexPath:indexPath];
if (cell) {
[cell updateChatViewBottomInset:bottomInset];
}
}
}
- (void)showChatLimitPopWithMessage:(NSString *)message {