I need create a method which detects keyboard input language . for example when keyboard language is French does something and when is English does something else
I search on the Internet and found UITextInputMode but I don't know how to use it , I would be grateful if you help me . thanks
It's quite simple, you can do it this way:
UITextInputMode *textInput = [UITextInputMode currentInputMode];
NSString *primaryLanguage = textInput.primaryLanguage;
NSLog(@"Current text input is: %@", primaryLanguage);
As noted in Apple docs, "The value of this property is a BCP 47 language code such as “es”, “en-US”, or “fr-CA”".
If you need to be notified about changes, you add your controller as observer for UITextInputCurrentInputModeDidChangeNotification
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With