views:

20

answers:

1

Hi,
I have got a tableViewController with one section and one cell.
How can I get the height between the navBar and the keyboard without any toolbar above it?
I tried this code:

self.view.bounds.size.height
but I get the height of the entire view down the navBar...
I'd like to get this size to assign it to the cell and to the textView inside it.

Thanks :)

+1  A: 

You can't get the height of the keyboard until it is displayed. You'll need to register for one of the keyboard notifications and then check the UIKeyboardFrameEndUserInfoKey value. This will give you the frame for the keyboard. Use this to adjust the height of your view.

I don't know what happens if you change the rowHeight property on a table that's already displayed, but my guess is that it should do what you want, once you compute the height to set it to.

Robot K
I don't want to get the height of the keyboard but the height of the part of view between the navBar and the keyboard, like showed in this image: http://bit.ly/cBQi6X :)
Matthew
Yes. You'll need to get the height of the keyboard and then subtract it from the height of your view controller's view. That will give you the difference between the nav bar and the keyboard.
Robot K
There's code very similar to what you want (but not exactly the same) at http://developer.apple.com/library/ios/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/KeyboardManagement/KeyboardManagement.html#//apple_ref/doc/uid/TP40009542-CH5-SW7.
Robot K
Thanks a lot! I resolved my problem with your advises ;)
Matthew