If we accept fragile answers, then in order to bring something new into the conversation:
CGRect rectInTableView = [tableView convertRect:textField.bounds fromView:textField]; NSUInteger indexOfCellContainingTextField = (NSUInteger)(rectInTableView.y / tableView.rowHeight);
Assumptions that make it fragile: (i) all rows are the same height; (ii) the height is set in table form. If you have not executed UITableViewDelegate -tableView:heightForRowAtIndexPath: then both of these assumptions will be considered true. You also take advantage of the fact that casting a positive float into an integer is rounded down.
I would say that although it is still not completely excluded from the assumptions, it is less fragile than the Mundi decision, because it only makes assumptions about the things that you directly control (i.e., about calibrating the cell), and not about what you are not doing (i.e. the view hierarchy UIKit uses internally to represent table views).
source share