Commit ccdc9079 authored by Steven杜宇's avatar Steven杜宇

// AI

parent 661245a8
......@@ -57,6 +57,11 @@ class YHAIMainChatViewController: YHBaseViewController {
}
}
}
v.keyBoardChangeBlock = {
[weak self] isKeyBoardShow in
guard let self = self else { return }
self.scrollToBottom()
}
return v
}()
......@@ -94,8 +99,10 @@ class YHAIMainChatViewController: YHBaseViewController {
func scrollToBottom() {
self.tableView.reloadData {
let indexPath = IndexPath(row: self.messages.count-1, section: 0)
self.tableView.scrollToRow(at: indexPath, at: .bottom, animated: true)
if self.messages.count > 0 {
let indexPath = IndexPath(row: self.messages.count-1, section: 0)
self.tableView.scrollToRow(at: indexPath, at: .bottom, animated: true)
}
}
}
......
......@@ -61,6 +61,11 @@ class YHAIRobotChatViewController: YHBaseViewController {
}
}
}
v.keyBoardChangeBlock = {
[weak self] isKeyBoardShow in
guard let self = self else { return }
self.scrollToBottom()
}
return v
}()
......@@ -106,8 +111,10 @@ class YHAIRobotChatViewController: YHBaseViewController {
func scrollToBottom() {
self.tableView.reloadData {
let indexPath = IndexPath(row: self.messages.count-1, section: 0)
self.tableView.scrollToRow(at: indexPath, at: .bottom, animated: true)
if self.messages.count > 0 {
let indexPath = IndexPath(row: self.messages.count-1, section: 0)
self.tableView.scrollToRow(at: indexPath, at: .bottom, animated: true)
}
}
}
......
......@@ -190,6 +190,7 @@ class YHAITabViewController: YHBaseViewController {
@objc func didJumoToAIChat() {
jumpToItemIndex(itemIndex: 1)
mainChatVC.bottomInputView.showKeyBoard()
}
}
......
......@@ -129,6 +129,10 @@ class YHAITextInputView: UIView {
NotificationCenter.default.removeObserver(self)
}
func showKeyBoard() {
self.textView.becomeFirstResponder()
}
func createUI() {
self.addSubview(whiteView)
......@@ -187,6 +191,8 @@ class YHAITextInputView: UIView {
}
self.setNeedsLayout()
self.layoutIfNeeded()
keyBoardChangeBlock?(isKeyboardShow)
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment