0

Are there Notifications or Delegate functions that detect switching keyboard language?

When I press Language Key in keyboard .. I need a delegate function that handle this in the code to change the direction of UITextfield.

Kara
  • 6,115
  • 16
  • 50
  • 57
Ziad Bou Ismail
  • 187
  • 2
  • 11
  • Check the below Link: http://stackoverflow.com/questions/11801587/is-there-a-delegate-call-when-ios-keyboard-language-changes – PREMKUMAR May 22 '14 at 12:07

1 Answers1

3

According to this answer:

The answer is that when you switch languages, the UIKeyboardDidShowNotification fires for each change

So you'll just have to register for that notification and then run your code:

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

- (void)keyboardWasShown:(NSNotification *)notification
{
   NSString * currentLanguage = [UITextInputMode currentInputMode].primaryLanguage;
}

Update

The above method doesn't work, however if we register to UITextInputCurrentInputModeDidChangeNotification we do get a callback.

Community
  • 1
  • 1
Gad
  • 2,867
  • 25
  • 35
  • UIKeyboardDidShowNotification is firing only when the uikeyboard will show but if i press languages key to change the language of the keyboard it is not firing anything :( – Ziad Bou Ismail May 22 '14 at 13:05
  • @ZiadBouIsmail You are correct. I guess it worked before and doesn't anymore. Please see my update. – Gad May 22 '14 at 13:41