I am getting trouble to deselect a cell in one click. As I click the cell, the label text inside it gets highlighted, and when i deselect the cell, 1st click deselects the highlighted label text color, turning it to black and then a 2nd click is needed to deselect the cell and leaving a trail of white colored text behind...I tried to disable the highlight feature of a label, but i am stuck here.You can see the setting for the label where it states color is white when highlighted.
I only implemented this func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath)
I also tried to set dateLabel.isHighlighted = false, but i am getting Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional
I have a dictionary with boolean value to track the state of a cell being selected or not, but this method doesnt solve my problem
Any help is appreciated and wish yall happy new years.
update:
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
//addToList[currentMonthIndex].append(indexPath)
//dayCollectionView.deselectItem(at: indexPath, animated: true)
let cell = collectionView.cellForItem(at: indexPath) as! CustomCell
cell.dateLabel.isHighlighted = false
cell.dateLabel.isUserInteractionEnabled = false
}
I have successfully disabled both but i still need double click to deselect it. It seems like the label inside would take one click. I am sure of this because otherwise the cell would have been deselected on the 2nd click as my global array that tracks the cell selection status would have been changed by that click.