简体   繁体   English

如何检测国际键盘的隐藏事件? iOS版

[英]How to detect hide event of international keyboard? iOS

How to detect hide event of international keyboard? 如何检测国际键盘的隐藏事件? UIKeyboardDidHideNotification doesn't seem to trigger. UIKeyboardDidHideNotification似乎没有触发。

Below related link is not helpful. 以下相关链接没有帮助。

detect the appear and disappear of international keyboard 检测国际键盘的出现和消失

MORE INFO 更多信息

This is how I setup notification for both UIKeyboardDidHideNotification and UIKeyboardDidShowNotification 这就是我为UIKeyboardDidHideNotificationUIKeyboardDidShowNotification设置通知的UIKeyboardDidShowNotification

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

-(void)keyboardDidShow:(NSNotification*)notification {
    NSLog(@"keyboardDidShow");
}
-(void)keyboardDidHide:(NSNotification*)notification {
    NSLog(@"keyboardDidHide");
}

keyboardDidShow is triggered twice. keyboardDidShow被触发两次。 First is when standard keyboard pops out. 首先是标准键盘弹出时。 Second is when the international keyboard pops out. 其次是国际键盘弹出的时候。

keyboardDidHide is NOT triggered when I hide the international keyboard. keyboardDidHide当我隐藏国际键盘不会被触发。 But it is triggered when standard keyboard is hidden. 但是在隐藏标准键盘时会触发它。

Am I missing something? 我错过了什么吗?

You don't get any notification if the user changes keyboards. 如果用户更改键盘,则不会收到任何通知。 Only if the keyboard appears or disappears. 仅在键盘出现或消失时。

Only solution I know of would be to observe or react to changes (Try KVO?) on 我所知道的唯一解决方案是观察或对变化做出反应(试试KVO?)

[UITextInputMode currentInputMode].primaryLanguage

See also: Detecting current iPhone input language 另请参阅: 检测当前的iPhone输入语言

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM