Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. func setupKeyboardObservers(){
  2. NotificationCenter.default.addObserver(self, selector: #selector(handleKeyboardDidShow), name: UIResponder.keyboardDidShowNotification, object: nil)
  3. }
  4.  
  5. override func viewDidDisappear(_ animated: Bool) {
  6. super.viewDidDisappear(animated)
  7. NotificationCenter.default.removeObserver(self)
  8. }
  9.  
  10. @objc func handleKeyboardDidShow(){
  11. print("did show LOL")
  12. if chatMessages.count > 0{
  13. let indexPath = NSIndexPath(item: chatMessages.count-1, section: 0)
  14. collectionView?.scrollToItem(at: indexPath as IndexPath, at: .top, animated: true)
  15. }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement