未使用表情符号键盘调用 UIKeyboardWillChangeFrame 通知 [英] UIKeyboardWillChangeFrame Notification not called with emoji keyboard

查看:50
本文介绍了未使用表情符号键盘调用 UIKeyboardWillChangeFrame 通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

First I had a UIViewController listenning for the UIKeyboardWillShow notification to adjust the screen for the keyboard. But every time I changed to emoji keyboard, the notification wasn't called.

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

So, I changed to UIKeyboardWillChangeFrame notification like this

NotificationCenter.default.addObserver(self, selector: #selector(self.keyboardChanged(notification:)), name: NSNotification.Name.UIKeyboardWillShow, object: nil)

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

It seems to work fine if I just change to emoji by tapping keyboard type.

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

However, if I press and hold keyboard type to select (my keyboard have more than one language) and select the emoji keyboard, the notification is not fired.

有人遇到过这种情况吗?有什么建议吗?

Anyone had something like this before? Any suggestions?

推荐答案

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

This is a bug in iOS 11, but there is a hacky temporary solution:

您可以聆听语言模式的变化:

You can listen language mode changes:

NotificationCenter.default.addObserver(self, selector: #selector(inputModeDidChange(_:)), name: .UITextInputCurrentInputModeDidChange, object: nil)

并检查表情符号:

if([[UITextInputMode currentInputMode].primaryLanguage isEqualToString:@"emoji"]) // layout again

这篇关于未使用表情符号键盘调用 UIKeyboardWillChangeFrame 通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆