iOS 8 get keyboard height iOS 8 get keyboard height ios ios

iOS 8 get keyboard height

The way you are doing it is correct but you might want to use UIKeyboardFrameEndUserInfoKey instead of UIKeyboardFrameBeginUserInfoKey. The end user key is the frame of the keyboard when it is done animating and on the screen, thus you know it will be that frame, while the begin key might not always match what the keyboard frame will be when it is shown.

There might also need to be extra considerations on orientation of the device, I have not looked into that, but for portrait, it should work.

The correct way to do this is to use the inputAccesorryView property of the UITextField.

The inputAccessoryView is automatically added above the keyboard regardless of keyboard size.

As the documentation states:

The default value of this property is nil. Assigning a view to this property causes that view to be displayed above the standard system keyboard (or above the custom input view if one is provided) when the text field becomes the first responder. For example, you could use this property to attach a custom toolbar to the keyboard

See more information here

You might need to do [self.view setNeedsLayout] instead of [self.view layoutIfNeeded].