Get keyboard height WITHOUT adding keyboard observers (like keyboardWillShow or keyboardWillHide)

zzzz Source

I have a requirement where in I need to add a view which will have the same height as of the device keyboard.

Since different devices have different height, is there a way to fetch keyboard height for device without registering to keyboard notifications?

I could save the keyboard height if the user opens the keyboard anywhere in the app but there is possibilities that the custom view can appear before the keyboard appears.



answered 2 weeks ago rmaddy #1

You can't. A user can have different keyboards installed. Responders can have custom inputViews and inputAccessoryViews. Keyboards can have other toolbars. The height resulting height of the keyboard and its accessories can be different for different responders on the same view. The height can't be determined for a specific case until the specific keyboard and its accessories are about to be displayed.

You need to rethink your requirement so that the height of the view can be adjusted as needed because that height can be different each time the keyboard appears.

comments powered by Disqus