leo
leo

Reputation: 549

Is there a way to know that iOS keyboard is really hidden (dismissed by user)?

I need a way to detect the case when user dismisses iOS keyboard manually, using "keyboard" button on keyboard. I tried to use UIKeyboardDidHideNotification, but quickly discovered that this event is also fired when user splits the keyboard, leaving it on screen.
Is there a way to know for sure that keyboard was really hidden?

Upvotes: 2

Views: 211

Answers (2)

leo
leo

Reputation: 549

To get solution I had to slightly modify my original implementation: I've replaced assigning nil to inputView member of my main view with creating and destroying custom invisible UIView<UIKeyInput> view to show and hide keyboard correspondingly. This allowed me to override this view's resignFirstResponder method which is always called on keyboard resigning - either in normal or in split state, when user dismisses keyboard using special button or when I remove it programmatically.

Upvotes: 1

Kyle Truscott
Kyle Truscott

Reputation: 1577

I believe that UIKeyboardDidHideNotification is only sent when the keyboard is truly gone. From the Apple docs:

Posted immediately after the dismissal of the keyboard.

However, you could also look to see if any of your inputs are currently the first responder:

BOOL keyboardUp = NO;

for (UIView *view in self.textInputs)
{
  if (view.isFirstResponder)
  {
    keyboardUp = YES;
    break;
  }
}  

Upvotes: 0

Related Questions