不使用表情符号键盘调用 UIKeyboardWillChangeFrame 通知
UIKeyboardWillChangeFrame Notification not called with emoji keyboard
首先我有一个 UIViewController 监听 UIKeyboardWillShow 通知来调整键盘的屏幕。但是每次我换成表情符号键盘,都没有调用通知。
所以,我改成了这样的 UIKeyboardWillChangeFrame 通知
NotificationCenter.default.addObserver(self, selector: #selector(self.keyboardChanged(notification:)), name: NSNotification.Name.UIKeyboardWillShow, object: nil)
如果我只是通过点击键盘类型更改为表情符号,似乎工作正常。
但是,如果我按住键盘类型 select(我的键盘有不止一种语言)和 select 表情符号键盘,则不会触发通知。
有人遇到过类似的事情吗?有什么建议吗?
这是 iOS 11 中的错误,但有一个 hacky 临时解决方案:
您可以收听语言模式变化:
NotificationCenter.default.addObserver(self, selector: #selector(inputModeDidChange(_:)), name: .UITextInputCurrentInputModeDidChange, object: nil)
并检查表情符号:
if([[UITextInputMode currentInputMode].primaryLanguage isEqualToString:@"emoji"]) // layout again
首先我有一个 UIViewController 监听 UIKeyboardWillShow 通知来调整键盘的屏幕。但是每次我换成表情符号键盘,都没有调用通知。
所以,我改成了这样的 UIKeyboardWillChangeFrame 通知
NotificationCenter.default.addObserver(self, selector: #selector(self.keyboardChanged(notification:)), name: NSNotification.Name.UIKeyboardWillShow, object: nil)
如果我只是通过点击键盘类型更改为表情符号,似乎工作正常。
但是,如果我按住键盘类型 select(我的键盘有不止一种语言)和 select 表情符号键盘,则不会触发通知。
有人遇到过类似的事情吗?有什么建议吗?
这是 iOS 11 中的错误,但有一个 hacky 临时解决方案:
您可以收听语言模式变化:
NotificationCenter.default.addObserver(self, selector: #selector(inputModeDidChange(_:)), name: .UITextInputCurrentInputModeDidChange, object: nil)
并检查表情符号:
if([[UITextInputMode currentInputMode].primaryLanguage isEqualToString:@"emoji"]) // layout again