15

In my app I have some complex logic surrounding the hiding and showing of the keyboard. I am interested in detecting when the user (who has an iPad) specifically taps on the iPad keyboard hide button:

alt text

I am not interested in detecting when the keyboard is supposed to hide, only when the user actually physically taps on this button. Any suggestions?

Thank you!

Jason
  • 14,517
  • 25
  • 92
  • 153

2 Answers2

21

I was looking for an exact same solution, and I did found it in the documentation after all. You get a whole package of keyboard notifications:

- UIKeyboardWillShowNotification
- UIKeyboardDidShowNotification
- UIKeyboardWillHideNotification
- UIKeyboardDidHideNotification
- UIKeyboardWillChangeFrameNotification
- UIKeyboardDidChangeFrameNotification

I was interested in "UIKeyboardWillHideNotification". So just implemented:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(KeyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];

Et voilà! Hope this helps, even it's an year late answer.

Viraj
  • 1,880
  • 22
  • 31
DZenBot
  • 4,806
  • 2
  • 25
  • 27
  • 2
    This notification is also send when view is rotating. I am interested in this key only and was wandering if you have found another solution? – Wojciech May 10 '13 at 10:00
0

I don't think Apple allows that, I'm afraid.

But maybe you could create an invisible view (view.opaque = FALSE; view.alpha = 0;) that's placed just above the aforementioned button which receives touches as the first responder (so that you get the event) and then forwards it to the next (the keyboard). However, I don't know if it's possible to place a view above the keyboard, even "illegally".

Constantino Tsarouhas
  • 6,846
  • 6
  • 43
  • 54