What is -[UITableViewDelegate willDisplayCell:forRowAtIndexPath:] for?
In all of my UITableView
programming, I've always configured my UITableViewCells
in -[UITableViewDataSource tableView:cellForRowAtIndexPath:]
. Now I've come across the -[UITableViewDelegate willDisplayCell:forRowAtIndexPath:]
method. That also seems like an appropriate place to do cell configuration.
My question is: what's the appropriate "division of labor" between these two methods? What should I do in one vs. the other?
You use that to configure things like font and text color. In the newer version of the iPhone, with certain table configurations, if you configure things like the label text color in the tableView:cellForRowAtIndexPath:
method, your changes will be lost at some point before the cell is actually displayed. Here you can do things like change the label's color, adjust background highlighting, such things as these.