I’m having trouble trying to scroll up a tableView when the user start editing a UITextField displayed in one of the cells.
My problem is that I can’t find a way to know the position of the UITextField in the view. If I try to do activeTextField.frame.origin.y, I get the position of the TextField inside the cell, but not inside the tableView.
The way I build the view is the following :
I’ve got a TableViewController, which creates cells using a custom class that initializes the UITextField. Then my TableViewController set the UITextField delegate to itself, so I can trigger the textFieldDidBeginEditing event. But if I try to NSLog the y origin of the TextField, I always get the same value for each UITextField, which is its position in the cell.
Any idea on how I can solve this?
It’s always confusing with these coordinate system changes …
This should work to get you the point in the table view coordinate system:
If you want to have it in a different view, you should replace tableView with the view you want to have the coordinate in.
And if you want to get the cell in the table the textField was in: