iPhone X simulator does not receive UIKeyboardWillChangeFrame notification

Viewed 266

Hi this is my first post in SO.

I'm using .UIKeyboardWillChangeFrame notification in order to get dynamic height of the keyboard and update other views accordingly.

But when I switch to an EMOJI or a Chinese Hand-writing keyboard in iPhone X simulator, UIKeyboardWillChangeFrame notification does not get called.

  • ENGLISH keyboard ---> EMOJI keyboard ( X, not called )
  • EMOJI keyboard ---> ENGLISH keyboard ( O, works fine )

It works just fine in simulators other than iPhone X (eg. iPhone 5, 6, plus..).

adding observer

NotificationCenter.default.addObserver(self,
                                           selector : #selector(self.keyboardWillChangeFrame(withNotification:)),
                                           name : .UIKeyboardWillChangeFrame,
                                           object : nil)

selector method

@objc func keyboardFrameWillChange(withNotification notification : Notification)
{
    if let size = (notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue
    {
        print("will display EMOJI with height : \(size.height)")
    }
} 

Only tested in iPhone X simulator and not in real device (hard to get one T_T)

XCode version : latest 9.1 (9B55) Simulator version : iPhone X (iOS 11.0.1), iPhone X (iOS 11.1)

0 Answers
Related