Make UITextField inside a table view visible scrolling
I have a UITableViewController, a bunch of sections and rows, and for each row I added a UITextField as a subview, right aligned in the row itself.
If the users taps on the row, I locally save the indexPath, make the corresponding text field become the first responder and finally, when the keyboard appears, I make the table view scroll so that the row remains visible.
开发者_如何转开发I am facing the problem to obtain the same behaviour when the user taps the text field instead. In this case the didSelectRowAtIndexPath: method isn't called, so I do not know how to tell the table view to scroll to make sure that the "selected" row is still visible.
Probably the whole process is not correct. Do you know a way to solve it?
Thanks a lot!
I'm not absolutely sure about this, but...
Set the userInteractionEnabled
property of the UITextField
to NO
. This way, the touch goes "through" the control, tapping the UITableViewCell
. When didSelectRowAtIndexPath:
is called, set the userInteractionEnabled
property of the UITextField
to YES
. When the editing is complete, change it back to NO
.
精彩评论