2014-05-22 54 views
0

是否有检测切换键盘语言的通知或委托功能?目标中的键盘语言C

当我按下键盘上的语言键..我需要一个委托函数,在代码中处理这个来改变UITextfield的方向。

+0

检查以下链接: http://stackoverflow.com/questions/11801587/is-there-a-delegate-call-when-ios-keyboard-language-changes – PREMKUMAR

回答

3

根据this answer

答案是,当你切换语言,该UIKeyboardDidShowNotification火灾每次更改

所以你只需要注册该通知,然后运行代码:

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

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

更新

上述方法不起作用,但是如果我们注册到UITextInputCurrentInputModeDidChangeNotification,我们确实会得到一个回调。

+0

UIKeyboardDidShowNotification只有当射击uikeyboard将显示,但如果我按语言键改变键盘的语言它不会发射任何东西:( –

+0

@ZiadBouIsmail你是对的,我猜它已经工作过,现在不再了,请看我的更新 – Gad

+0

谢谢@它工作的GadMarkovits :) –