|
@@ -139,6 +139,24 @@ class ChatViewControllerNew: UITableViewController {
|
|
selector: #selector(setTextDraft),
|
|
selector: #selector(setTextDraft),
|
|
name: UIApplication.willResignActiveNotification,
|
|
name: UIApplication.willResignActiveNotification,
|
|
object: nil)
|
|
object: nil)
|
|
|
|
+ notificationCenter.addObserver(self, selector: #selector(keyboardWillShow(_:)), name: UIResponder.keyboardWillShowNotification, object: nil)
|
|
|
|
+ notificationCenter.addObserver(self, selector: #selector(keyboardWillHide(_:)), name: UIResponder.keyboardWillHideNotification, object: nil)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @objc func keyboardWillShow(_ notification: Notification) {
|
|
|
|
+ if let keyboardSize = (notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue {
|
|
|
|
+ if self.view.frame.origin.y == 0 && tableView.inputAccessoryView?.frame.height ?? 0 < keyboardSize.height {
|
|
|
|
+ self.view.frame.origin.y -= keyboardSize.height
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @objc func keyboardWillHide(_ notification: Notification) {
|
|
|
|
+ if let keyboardSize = (notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue {
|
|
|
|
+ if self.view.frame.origin.y != 0 {
|
|
|
|
+ self.view.frame.origin.y += keyboardSize.height
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
private func startTimer() {
|
|
private func startTimer() {
|