开发者

How does Apple want us to set up our table view cells?

开发者 https://www.devze.com 2023-04-13 04:38 出处:网络
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, inst

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号