Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func setupKeyboardObservers(){
- NotificationCenter.default.addObserver(self, selector: #selector(handleKeyboardDidShow), name: UIResponder.keyboardDidShowNotification, object: nil)
- }
- override func viewDidDisappear(_ animated: Bool) {
- super.viewDidDisappear(animated)
- NotificationCenter.default.removeObserver(self)
- }
- @objc func handleKeyboardDidShow(){
- print("did show LOL")
- if chatMessages.count > 0{
- let indexPath = NSIndexPath(item: chatMessages.count-1, section: 0)
- collectionView?.scrollToItem(at: indexPath as IndexPath, at: .top, animated: true)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement