IPad Keyboard Height Change Notification

I am trying to show a UITextField on top of an iPad keyboard.

I managed to get the height of the keyboard when it was presented with a notification.

However, on the iPad, changing the keyboard input language → most likely to Japanese, the height of the keyboard changed because the text hypothesis area was shown on the keyboard, which caused my UITextfield area to be hidden ....

Does anyone know how I can get a notification of a change in height or in any other way?

+6
source share
2 answers

The answer is that when switching languages, UIKeyboardDidShowNotification triggered for each change, so you always get an updated height.

See my answer here on how to set up the show and hide answers and get the height.

+2
source

Swift

UIKeyboardDidShowNotification will no longer override keyboard resizing.

Use UIKeyboardWillChangeFrameNotification :

 NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(instance.keyboardWillChange(_:)), name:UIKeyboardWillChangeFrameNotification, object: nil) 

in function:

 let targetSize = (notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.CGRectValue() 

Important: this event will also be fired when the keyboard opens and UIKeyboardWillShowNotification ; it can replace both UIKeyboardWillShowNotification and UIKeyboardWillHideNotification if only dimensions are needed

+1
source

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


All Articles