修复聊天最后一条跑到最上面的问题
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user