For tableviews, I have never had an issue with a text label persisting after a cell is reused.
When you reload a tableview after the datasource has changed, the tableviewcells get the latest data and draw themselves accordingly.
However, I am now having this problem with an attributed label. After removing an item from the datasource so that the tableviewcell gets re-used the attributed label persists in the cell. Needless to say, the leftover attributed label has nothing to do with what should be in the cell. It's just attached to the cell and won't go away.
The problem is described here:
In the above answer, the person said he got rid of the attributed label by setting it to nil prior to doing anything with the regular text label.
transactionDescriptionLabel.attributedText = nil
transactionValueLabel.attributedText = nil
Or, if I reset the attributedText first, and then reset the text, it also works:
transactionDescriptionLabel.attributedText = nil
transactionValueLabel.attributedText = nil
transactionDescriptionLabel.text = nil
transactionValueLabel.text = nil
Setting the attributed label to nil seems to solve the problem for me but I have never had to set a regular textLabel to nil before and am trying to get my arms around why I would have to set the attribute label to nil.
When you have an attribute label, is it necessary to set it to nil when you dequeue the cell? Or, apart from setting it to an empty string, what is the proper way to get it to disappear when you are no longer displaying it in the tableview?
Thanks in advance for any suggestions.