0

I have a Cell comprising of an Image View inside a UI Collection View in a custom keyboard extension. Everything looks good except when I try to select an item in the collection view nothing happens. Any idea/suggestions?

Yes, I have attached delegates.

override func viewDidLoad() {
        super.viewDidLoad()
        self.collectionView.delegate = self
        self.collectionView.dataSource = self
        self.collectionView.allowsSelection = true
        self.collectionView.allowsMultipleSelection = false
}

//This works

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = self.collectionView.dequeueReusableCell(withReuseIdentifier: "cell",for: indexPath)
        cell.backgroundColor = #colorLiteral(red: 0, green: 0.4117647059, blue: 0.8509803922, alpha: 1)
        return cell
    }


//This doesnt

    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
        let cell = self.collectionView.dequeueReusableCell(withReuseIdentifier: "cell",for: indexPath)
        cell.backgroundColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
    }

Any idea/Suggestions?

EDIT:

Uploaded my code to github for better suggestions :)

Shivam Tripathi
  • 1,405
  • 3
  • 19
  • 37
Kamil Kamili
  • 1,757
  • 5
  • 24
  • 39

0 Answers0