When a customized UITableViewCell is queued (e.g. it goes off the screen) how much of it开发者_JAVA百科's setup is retained? For example:
- Are any views added to it previously remain in place (eg [cell.contentView addSubview:someUILabel]; )
- The configuration of such subviews? (e.g. fonts)
- Data from such subviews?
Just trying to understand when I do dequeueReusableCellWithIdentifier and get a cell from the queue, how re-work, if any, do I need beyond changing the data (e.g. like changing the text values in the UILabels subviews).
UITableView won't alter the cell while it is in the queue however it will call -prepareForReuse before dequeuing the cell and that may reset attributes of the cell returned by -dequeueReusableCellWithIdentifier:
. As suggested by the documentation, the cells content should remain unaffected and it will be up to your delegate to modify the cell as needed before it is reused.
It doesn't do anything to the cell that you don't tell it to. All it does is place it in a new spot. In your code you will need to manually change anything that is unique to the cell that is being asked for.
System guard all data for UITableViewCell including any custom view (added as a subView to UITableViewCell), fonts (applied either on the custom view or directly on UITableViewCell) and the data with custom view.
精彩评论