Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 795
Greg Maletic Avatar asked Dec 11 '09 19:12

Greg Maletic


1 Answers

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.

like image 106
Jason Coco Avatar answered Sep 21 '22 10:09

Jason Coco