I have a UICollectionView. It is filled with cells which include an image view and a label.
When one taps on a cell the text just disappears. How can I stop this from happening?
Extra information:
The collection view is within a container connected to a baseVC.
Cells and most of their content are added in its xib file. Everything shows up correctly. Expect when tapping, where text disappears and then reappears.
Also note that the label does not disappear, only the text.
The custom text is added when calling a cells: func setup(profImage: String, contentView: String, titleLabel: String, subtitleLabel: String) and even when disabling the text from being added the default labels still disappear on tap.
I would make sure the label is added to the contentView of the cell and not just the "top-most" view of the cell. Maybe the way the xib is setup is not right. Make sure it is UICollectionViewCell in the xib etc. You could also post pictures of how you have setup the xib.
Also, to debug, I would remove any code that deals with the cell that is not revolved around the label (for example, remove the animations until you fixed the bug). That will allow you to zone in on the issue. Or, another way, just begin from scratch and re-create the cell (with only the label). Getting a label to display is not rocket science, but you can make it rocket science if you do not build what is going on step-by-step.
Another potential issue is layout. Is the layout done right? And maybe it breaks (for some reason) when you highlight.
Try using UILabel's highlighted text color property:
The highlight color applied to the label’s text.
@property(nonatomic, strong) UIColor *highlightedTextColor;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With