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

查看:828
本文介绍了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中的一个错误,但有一个 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天全站免登陆