diff --git a/Visual_Novel_iOS/Src/Modules/Chat/Session/SessionController+Input.swift b/Visual_Novel_iOS/Src/Modules/Chat/Session/SessionController+Input.swift index b02d7ae..4655ac0 100755 --- a/Visual_Novel_iOS/Src/Modules/Chat/Session/SessionController+Input.swift +++ b/Visual_Novel_iOS/Src/Modules/Chat/Session/SessionController+Input.swift @@ -50,6 +50,7 @@ extension SessionController { let scrToBottomBtn = UIButton(type: .custom) scrToBottomBtn.setImage(UIImage(named: "chat_scr_bottom"), for: .normal) + scrToBottomBtn.addTarget(self, action: #selector(scrToBottomBtnTap), for: .touchUpInside) let stackView = UIStackView(arrangedSubviews: [scrToBottomBtn, exchangeBtn]) stackView.spacing = 10.0 @@ -142,7 +143,14 @@ extension SessionController { } // MARK: - Helper - + @objc func scrToBottomBtnTap() { + let lastSection = tableView.numberOfSections - 1 + let lastRow = tableView.numberOfRows(inSection: lastSection) - 1 + if lastSection >= 0, lastRow >= 0 { + let ip = IndexPath(row: lastRow, section: lastSection) + tableView.scrollToRow(at: ip, at: .bottom, animated: true) + } + } func hideAllBottomViews(except:[UIView]? = nil){ let viewsExcept = except ?? []