iOS 10, 9 all the way down to 5
UIKeyboardDidChangeFrameNotification
Posted immediately after a change in the keyboard’s frame.
The notification object is nil. The userInfo dictionary contains information about the keyboard. Use the keys described in Keyboard Notification User Info Keys to get the location and size of the keyboard from the userInfo dictionary.
Tested on iPhone 6, iOS 10, 9, 8.4 (linked, built, ran, see logs below).
The NSNotification dictionary shows the inversion of CGRect values in UIKeyboardFrameBeginUserInfoKey & UIKeyboardFrameEndUserInfoKey, and all 4 UIKeyboard__Notification are fired when the predictive accessory view is changed.
Swift 3
func addObserver(forName: Notification.Name) {
NotificationCenter.default.addObserver(forName: forName,
object: nil,
queue: OperationQueue.main)
{ (note:Notification!) -> Void in
print("\(forName): \(note)")
}
}
addObserver(forName: .UIKeyboardWillShow)
addObserver(forName: .UIKeyboardDidShow)
addObserver(forName: .UIKeyboardWillChangeFrame)
addObserver(forName: .UIKeyboardDidChangeFrame)
Turning Predictive ON

log:
UIKeyboardWillChangeFrameNotification:
UIKeyboardWillShowNotification:
UIKeyboardDidChangeFrameNotification:
UIKeyboardDidShowNotification:
userInfo = {
UIKeyboardBoundsUserInfoKey = "NSRect: {{0, 0}, {375, 258}}";
UIKeyboardCenterBeginUserInfoKey = "NSPoint: {187.5, 554.5}";
UIKeyboardCenterEndUserInfoKey = "NSPoint: {187.5, 538}";
UIKeyboardFrameBeginUserInfoKey = "NSRect: {{0, 442}, {375, 225}}";
UIKeyboardFrameEndUserInfoKey = "NSRect: {{0, 409}, {375, 258}}";
}
Turning Predictive OFF

log:
UIKeyboardWillChangeFrameNotification:
UIKeyboardWillShowNotification:
UIKeyboardDidChangeFrameNotification:
UIKeyboardDidShowNotification:
userInfo = {
UIKeyboardBoundsUserInfoKey = "NSRect: {{0, 0}, {375, 225}}";
UIKeyboardCenterBeginUserInfoKey = "NSPoint: {187.5, 538}";
UIKeyboardCenterEndUserInfoKey = "NSPoint: {187.5, 554.5}";
UIKeyboardFrameBeginUserInfoKey = "NSRect: {{0, 409}, {375, 258}}";
UIKeyboardFrameEndUserInfoKey = "NSRect: {{0, 442}, {375, 225}}";
}
► Find this solution on GitHub and additional details on Swift Recipes.