Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get keyboard height WITHOUT relying on notifications

Tags:

ios

ipad

I know how to set up an NSNotification observer to detect when the keyboard shows/hides. From this I can get the height of the keyboard. But what happens if the device is rotated while the keyboard is still showing?

Is there a way to get the height of the keyboard in this new state? Since the keyboard is still showing a new notification will not be triggered.

like image 732
Steve Barden Avatar asked Aug 15 '13 18:08

Steve Barden


1 Answers

You still have to use NSNotificationCenter, but you have to observe a different key. The key you're looking for is UIKeyboardDidChangeFrameNotification which according to the docs is posted immediately after a change in the keyboard’s frame.

like image 198
Mick MacCallum Avatar answered Sep 24 '22 02:09

Mick MacCallum