Swift
UIKeyboardDidShowNotification will no longer override keyboard resizing.
Use UIKeyboardWillChangeFrameNotification :
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(instance.keyboardWillChange(_:)), name:UIKeyboardWillChangeFrameNotification, object: nil)
in function:
let targetSize = (notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.CGRectValue()
Important: this event will also be fired when the keyboard opens and UIKeyboardWillShowNotification ; it can replace both UIKeyboardWillShowNotification and UIKeyboardWillHideNotification if only dimensions are needed
source share