UIKeyboardWillChangeFrame Notification not called with emoji keyboard

First I had a UIViewController that listened for a UIKeyboardWillShow notification to adjust the screen for the keyboard. But every time I switched to the emoji keyboard, a notification was not triggered.

So, I changed to a UIKeyboardWillChangeFrame notification like this

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

This seems like normal if I just switch to emoji by pressing the keyboard type.

However, if I press and hold the type of keyboard to select (I have more than one language on the keyboard) and select the emoji keyboard, the notification will not start.

Has anyone had something like this before? Any suggestions?

+5
source share
1 answer

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

You can listen to language mode changes:

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

And check emoji:

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

Source: https://habr.com/ru/post/1271912/


All Articles