UIKeyboardWillChangeFrame通知未使用表情符号键盘调用

Gus*_*zOl 5 keyboard notifications ios emoji swift

首先我有一个UIViewController监听UIKeyboardWillShow通知来调整键盘的屏幕.但每次我更改为表情符号键盘时,都没有调用通知.

所以,我改变了这样的UIKeyboardWillChangeFrame通知

NotificationCenter.default.addObserver(self, selector: #selector(self.keyboardChanged(notification:)), name: NSNotification.Name.UIKeyboardWillShow, object: nil)
Run Code Online (Sandbox Code Playgroud)

如果我只是通过点击键盘类型更改为表情符号似乎工作正常.

但是,如果我按住键盘类型进行选择(我的键盘有多种语言)并选择表情符号键盘,则不会触发通知.

以前有人这样吗?有什么建议?

Tun*_*alı 5

这是iOS 11中的一个错误,但有一个hacky临时解决方案:

您可以收听语言模式更改:

NotificationCenter.default.addObserver(self, selector: #selector(inputModeDidChange(_:)), name: .UITextInputCurrentInputModeDidChange, object: nil)
Run Code Online (Sandbox Code Playgroud)

并检查表情符号:

if([[UITextInputMode currentInputMode].primaryLanguage isEqualToString:@"emoji"]) // layout again
Run Code Online (Sandbox Code Playgroud)