13

I have found that UIKeyboardWillShowNotification and UIKeyboardDidShowNotification are not generated when an undocked/split keyboard appears in iOS 5. For instance, tap into a text field to show the keyboard (notifications are generated), undock the keyboard, tap out of the text field to dismiss the keyboard, tap on the text field again to show the undocked keyboard (notifications are not generated).

Is there any way to detect when the keyboard appears regardless of whether it is docked or not?

Meet Doshi
  • 4,241
  • 10
  • 40
  • 81
titaniumdecoy
  • 18,900
  • 17
  • 96
  • 133
  • Did you find any solution ? I'm facing the very same issue, UIKeyboardDidShowNotification is not delivered when using iOS 5 and keyboard is undocked. – Tushar Oct 18 '11 at 11:18
  • 2
    If I find a solution I will post it here. – titaniumdecoy Oct 18 '11 at 18:37
  • Similar question here: http://stackoverflow.com/questions/8100443/has-anyone-found-a-good-way-of-using-the-new-ios5-keyboard-events – titaniumdecoy Apr 14 '12 at 01:20
  • 1
    yes, those notification won't be posted when the keyboard undocked, because the user can reposition the keyboard and generally you won't need to handle the view behind the keyboard than you must do in the case of the docked keyboards which covers the bottom part of the screen, and the user are not able to reach the e.g. cells in a table view or buttons, etc... – holex Jul 17 '13 at 08:52

2 Answers2

10

You need to observe UIKeyboardWillChangeFrameNotification and UIKeyboardDidChangeFrameNotification instead. When you get them, you can look at the value for UIKeyboardFrameEndUserInfoKey (if it exists, it doesn't always while dragging the keyboard) and see if that rect intersects the window to see if the keyboard is now on or off screen.

smparkes
  • 13,807
  • 4
  • 36
  • 61
4

If the keyboard appears undocked / split, you don't need to detect it. The whole point of the undocked / split keyboard is that the user can move it freely if it's in the way.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • 13
    Obviously I have a reason for wanting to detect this event or I wouldn't have asked the question. – titaniumdecoy Dec 31 '11 at 07:18
  • 4
    Yes - I'm just trying to reverse-engineer Apple's thinking. What they've done is to preserve the behavior of the "show" and "hide" notifications with respect to the docked position of the keyboard. Thus you can perfectly well get by with your old code, because if the keyboard is undocked, the user can move it. Alternatively, you can switch to `UIKeyboardDidChangeFrameNotification` (or just add it to the repertory of notifications. – matt Dec 31 '11 at 15:21