I was told by someone helping me out with some code the other day that Apple wants developers to use tableView:willDisplayCell:forRowAtIndexPath:
for setti开发者_如何转开发ng up the custom cells, instead of tableView:cellForRowAtIndexPath:
.
I want to know if this is correct, and if so what are the benefits?
Just quoting the protocol reference:
This method gives the delegate a chance to override state-based properties set earlier by the table view, such as selection and background color. After the delegate returns, the table view sets only the alpha and frame properties, and then only when animating rows as they slide in or out.
What I get from this, is that it is encouraged to use this method only for styling the background / selected properties, but not the whole setup of the cell.
精彩评论