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
  • 5,996
  • 16
  • 49
  • 56
Ziad Bou Ismail
  • 157
  • 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,809
  • 23
  • 35