views:

155

answers:

2

Hello,

In my view I have a toolbar with a button at the top and a table view underneath, like in the following picture: alt text

An you can see there are text fields in the cells of the table view. The problem appears when I want to edit the tet fields which are in the bottom of the table view. As you can imagine the keyboard overlaps the text fields. Let say I want to edit the fields in the C section, the result is following: alt text

I tried different approaches for moving the table view, but I always end up with the toolbar being hidden. In one cae the toolbar was moving up with together with the table view, in the second case the table view overlaps the toolbar: alt text

All the ideas how to move the table view to make the cell being edited visible together with having the toolbar visible? How to move/resize the table view?

Thanks!

A: 

You could use the tableview contentInsets property:

//216 is keyboard height
theTable.scrollIndicatorInsets = UIEdgeInsetsMake(0, 0, 216, 0);
theTable.contentInset = UIEdgeInsetsMake(0, 0, 216, 0);
Rengers
Could you explain what this code is supposed to do? I'm not sure if I understand how it should work.
Jakub
The contentInset defines the inset of the table view content. If you know HTML/CSS, it is kind of like a padding. If you create a inset of `(100, 0, 0, 0)`, the first row will not start at 0px from the top, but at 100px. Same goes for the bottom, left and right.The scrollIndicatorInsets are essentially the same, but for the scroll indicators at the right of the table.When a UITextField becomes first responder, run this code and it will 'resize' the table view. When it resignes, just run it again with `UIEdgeInsetsMake(0, 0, 0, 0)`.
Rengers
Thanks for the clarification. Unfortunately it doesn't work.
Jakub
A: 

Have you tried scrolling the concerned row to the top of the tableview by using scrollToRowAtIndexpath?

Hetal Vora
This will work also, but I don't think it's possible when it is the last row.
Rengers
Yes, @Rengers is right. This was discussed here: http://stackoverflow.com/questions/478931/uitableview-scrolltorowatindexpath-scrolls-but-goes-back-to-1st-row
Jakub