Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does a UITextField with first responder status in a UITableViewCell prevent cell re-use?

In a UITableView where the cells contain UITextField objects, does having one of those UITextField objects be the first responder prevent its cell from being re-used?

For example, with a UITableView that has more rows than will fit on the screen, one can tap on a UITextField to bring up the keyboard for the field in that cell. Then scroll the table view to make that cell go off screen. When scrolling back to the cell, I can see calls to -tableView:cellForRowAtIndexPath: for all the cells, except the one that contains the UITextField that currently has first responder status.

This behavior leads me to believe that iOS is aware that my cell contains the first responder and thus chooses not to discard the cell, thus not needing to call the data source to get the cell when it scrolls back into view.

This behavior is desirable, but I am concerned because I have not seen any documentation that indicates that this behavior is guaranteed, and I would hate to rely on it if there are conditions where it isn't true.

Can anyone point me at some documentation about table view cell re-use and first responders that covers this situation?

like image 298
GBegen Avatar asked Nov 08 '11 01:11

GBegen


1 Answers

There is no such reference in the official iOS SDK documentation. You are correct to be concerned that this behavior you are observing is not guaranteed and should not be relied upon.

like image 188
Peter Cetinski Avatar answered Oct 17 '22 03:10

Peter Cetinski