floating keyboard doesn't send keyboard notifications

It seems like the floating keyboard in iPadOS only sends UIKeyboardDidChangeFrameNotification. It doesn't send UIKeyboardWillShowNotification, UIKeyboardDidShowNotification, UIKeyboardWillHideNotification or UIKeyboardDidHideNotification.


Is this by design? Is it documented somewhere, but I'm just missing it?

Replies

As floating keyboard is a floating window, always visible on top: it does not hide, hence doesn't need to show.


So it seems logical it does not send those notifications. By design.

But it's not always visible. I would still expect it to send the will/did show notifications when it appears. And send the will/did hide notifications when it's dismissed. If this is in fact by design, it should be documented.


Having to check whether the starting/ending frame's bounds is zero seems incredibly backwards to me.

OK, my mistake, I've not used yet.


What would you want to perform on notification as willShow ?

Usually, yhose notifications are used to move views that are hidden by keyboard.

With floating keyboard, that's no more needed or desirable.

It's in an existing application, so the change actually breaks some functionality.


In the app on the store, certain on-screen buttons are disabled when the keyboard appears. They're re-enabled when you press submit, dismissing the keyboard. Since the notifications are no longer sent, those buttons never get re-enabled.


Basically, the text entry is a modal operation, and the existing code relies on those notifications to exit that mode. Might not be the best design, but I didn't write the original code.

Hi, I encountered a similar issue in my app: My app shows and hides an edit area (text field + other controls) when the keyboard hides and shows. The iPad floating and split keyboards presented a problem because as mentioned, they only send frame change events.

I track the use of the traditional iPad keyboard by watching UIKeyboardWillShowNotification and UIKeyboardWillHideNotification events, and for floating and split keyboards, this is my solution when I get a UIKeyboardWillChangeFrameNotification notification:

Code Block
// n is NSNotification * from UIKeyboardWillChangeFrameNotification
NSDictionary *keyboardInfo = [n userInfo];
CGRect keyboardFrameEndRect = [[keyboardInfo valueForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
NSUInteger animationCurveOption = [[keyboardInfo valueForKey:UIKeyboardAnimationCurveUserInfoKey] integerValue];
if (CGRectEqualToRect(keyboardFrameEndRect, CGRectZero) || // Floating keyboard is HIDING or BEING DRAGGED by the user
keyboardFrameEndRect.origin.y >= self.view.frame.size.height) { // Split keyboard is moving off screen
if (animationCurveOption != 0) { // When animation curve is zero, the keyboard is being hidden. (Otherwise, it's being moved)
// TODO: FLOATING OR SPLIT KEYBOARD IS HIDING
}
} else {
// TODO: FLOATING OR SPLIT KEYBOARD IS SHOWING
}