4

How to detect hide event of international keyboard? UIKeyboardDidHideNotification doesn't seem to trigger.

Below related link is not helpful.

detect the appear and disappear of international keyboard

MORE INFO

This is how I setup notification for both UIKeyboardDidHideNotification and UIKeyboardDidShowNotification

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardDidShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidHide:) name:UIKeyboardDidHideNotification object:nil];

-(void)keyboardDidShow:(NSNotification*)notification {
    NSLog(@"keyboardDidShow");
}
-(void)keyboardDidHide:(NSNotification*)notification {
    NSLog(@"keyboardDidHide");
}

keyboardDidShow is triggered twice. First is when standard keyboard pops out. Second is when the international keyboard pops out.

keyboardDidHide is NOT triggered when I hide the international keyboard. But it is triggered when standard keyboard is hidden.

Am I missing something?

Community
  • 1
  • 1
ngzhongcai
  • 1,793
  • 3
  • 23
  • 31
  • Same to `UIKeyboardWillHideNotification` ? How did you setup your notification? – Kjuly Jun 30 '13 at 08:42
  • Seems right, you can take a try with `UIKeyboardWillHideNotification` instead `UIKeyboardDidHideNotification`. – Kjuly Jul 01 '13 at 08:16
  • Ney, I did. UIKeyboardWillHideNotification didn't work. But obviously there's a way to do this because all major messaging apps are able to detect this, ie adjust visible area when international keyboard triggers. Just not sure how they do it. – ngzhongcai Jul 01 '13 at 08:30
  • 2
    Take a look at [this link](http://www.adevelopingstory.com/blog/2012/05/the-ipad-split-keyboard-and-missing-notifications.html). The main idea is to use `UIKeyboardDidChangeFrameNotification` to adapt your UI when the keyboard frame changes. – Sergiy Salyuk Aug 08 '13 at 15:39
  • Thanks! This is the right handle. Been looking for this. You want to repost this as answer? – ngzhongcai Aug 08 '13 at 16:02

1 Answers1

0

You don't get any notification if the user changes keyboards. Only if the keyboard appears or disappears.

Only solution I know of would be to observe or react to changes (Try KVO?) on

[UITextInputMode currentInputMode].primaryLanguage

See also: Detecting current iPhone input language

Community
  • 1
  • 1
Cocoanetics
  • 8,171
  • 2
  • 30
  • 57
  • currentInputMode is deprecated in ios 7 – pickwick Oct 07 '13 at 22:14
  • There is an undocumented notification `UIKeyboardLayoutDidChangedNotification` (sic) that you might want to try to listen too. – Cocoanetics Oct 10 '13 at 16:29
  • Also there is `UITextInputCurrentInputModeDidChangeNotification` which you might want to try or observing the `+activeInputModes` property of `UITextInputMode`. – Cocoanetics Oct 10 '13 at 16:32