I am aware of the WillShow keyboard and keyboard Highlight events:
override public func viewWillAppear(animated: Bool) { NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWillShow:", name: UIKeyboardWillShowNotification, object: nil) NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWillHide:", name: UIKeyboardWillHideNotification, object: nil) }
But with the new keyboards in iOS8, the keyboard can change without firing the keyboard, and I was wondering how to call the keyboard resize function. Somebody knows? Thanks.
Edit: now it causes a frame change, but using this code:
if let keyboardSize = (notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.CGRectValue() { NSLog("\(keyboardSize.height)") }
It returns the previous height of the keyboard, for example, when the frame changes to “224.0”, it returns “253.0”, as if the height had not been updated in time when the code was called, and when it goes, it should “253.0”, it returns the old height which is equal to "224.0"
Edit 2: Instead of using "UIKeyboardFrameBeginUserInfoKey" I used "UIKeyboardFrameEndUserInfoKey" and it works now.
source share