SHARE
TWEET

Untitled

a guest Jun 27th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top