Skip to content

Commit 59e9632

Browse files
committed
fix scroll raise keyboard incorrect
1 parent 58da7a3 commit 59e9632

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

Sources/EaseChatUIKit/Classes/UI/Components/Chat/Views/MessageInputBar.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,17 @@ extension MessageInputBar: UITextViewDelegate {
445445
self.textViewFirstResponder?(true)
446446
}
447447

448+
public func endSuperScroll() {
449+
if let list = self.superview?.viewWithTag(111) as? UITableView {
450+
let indexPath = IndexPath(row: list.numberOfRows(inSection: 0) - 1, section: 0)
451+
if indexPath.row >= 0 {
452+
list.scrollToRow(at: indexPath, at: .none, animated: false)
453+
}
454+
}
455+
}
456+
448457
@objc private func keyboardWillShow(notification: Notification) {
458+
self.endSuperScroll()
449459
if !self.inputField.isFirstResponder {
450460
return
451461
}
@@ -455,7 +465,7 @@ extension MessageInputBar: UITextViewDelegate {
455465
guard let frame = notification.chat.keyboardEndFrame else { return }
456466
guard let duration = notification.chat.keyboardAnimationDuration else { return }
457467
self.keyboardHeight = frame.height
458-
if frame.height < 200 {
468+
if frame.height < 216 {
459469
return
460470
}
461471
self.attachment.isSelected = false
@@ -482,6 +492,7 @@ extension MessageInputBar: UITextViewDelegate {
482492

483493
@objc open func showEmojiKeyboard() {
484494
self.emoji?.isUserInteractionEnabled = true
495+
self.endSuperScroll()
485496
self.collapsedState = false
486497
if self.rightView.isSelected {
487498
self.keyboardHeight = 256+BottomBarHeight
@@ -529,6 +540,7 @@ extension MessageInputBar: UITextViewDelegate {
529540
@objc open func showExtensionMenus() {
530541
self.collapsedState = false
531542
self.extensionMenus.isUserInteractionEnabled = true
543+
self.endSuperScroll()
532544
if !self.subviews.contains(self.extensionMenus) {
533545
self.addSubview(self.extensionMenus)
534546
}

Sources/EaseChatUIKit/Classes/UI/Components/Chat/Views/MessageListView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ public let MessageInputBarHeight = CGFloat(52)
219219
private var CellTypes: [MessageCell.Type] = []
220220

221221
public private(set) lazy var messageList: UITableView = {
222-
UITableView(frame: CGRect(x: 0, y: 0, width: self.frame.width, height: self.frame.height-BottomBarHeight-MessageInputBarHeight), style: .plain).delegate(self).dataSource(self).tableFooterView(UIView()).separatorStyle(.none).backgroundColor(.clear)
222+
UITableView(frame: CGRect(x: 0, y: 0, width: self.frame.width, height: self.frame.height-BottomBarHeight-MessageInputBarHeight), style: .plain).delegate(self).dataSource(self).tableFooterView(UIView()).separatorStyle(.none).backgroundColor(.clear).tag(111)
223223
}()
224224

225225
private var oldFrame = CGRect.zero

0 commit comments

Comments
 (0)