-
-
Save zontan/41e59cca8da22d0dd40c460d92db16fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
messageList.count | |
} | |
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
let cell = tableView.dequeueReusableCell(withIdentifier: "chatCell", for: indexPath) | |
let message = messageList[indexPath.row] | |
cell.textLabel?.text = message | |
cell.textLabel?.numberOfLines = 0 | |
cell.backgroundColor = .clear | |
cell.textLabel?.textColor = .systemBlue | |
return cell | |
} | |
@objc func keyboardWillShow(notification: NSNotification) { | |
guard let userInfo = notification.userInfo else { return } | |
guard let keyboardSize = userInfo[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue else { return } | |
let keyboardFrame = keyboardSize.cgRectValue | |
bottomConstraint?.constant = 20 + keyboardFrame.height | |
} | |
@objc func keyboardWillHide(notification: NSNotification) { | |
bottomConstraint?.constant = 110 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment