Просто вы должны получить строку launguage кода с помощью [UITextInputMode currentInputMode].primaryLanguage
но вы должны добавить наблюдателя, потому что если клавиатура launguage является chane, то этот наблюдатель уведомляет, что язык изменен.
Objective-C:
- (void)viewDidLoad
{
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(changeInputMode:)
name:UITextInputCurrentInputModeDidChangeNotification object:nil];}
}
//This method prints the currently selected input language (like "en_US" or "de_DE"):
-(void)changeInputMode:(NSNotification *)notification
{
NSString *inputMethod = [[UITextInputMode currentInputMode] primaryLanguage];
NSLog(@"inputMethod=%@",inputMethod);
}
Свифта:
class ViewController: UIViewController
{
override func viewDidLoad() {
super.viewDidLoad()
NSNotificationCenter.defaultCenter().addObserver(self,
selector: "changeInputMode:",
name: UITextInputCurrentInputModeDidChangeNotification, object: nil)
}
func changeInputMode(notification : NSNotification)
{
let inputMethod = UITextInputMode.currentInputMode().primaryLanguage
println("inputMethod: \(inputMethod)")
}
}