I have a custom UICollectionViewCell
with a button called collectionViewButton
inside the cells.
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! CustomCollectionViewCell
cell.collectionViewButton.tag = indexPath.item
cell.collectionViewButton.addTarget(self, action:#selector(CollectionViewController.collectionButtonAction(_:)), for: .touchUpInside)
...
}
which calls the function:
func collectionButtonAction(_ sender: UIButton){
...
}
When the button is pressed the error:
'[ProjectName.CustomCollectionViewCell collectionButtonAction:]: unrecognized selector sent to instance' appears.
CustomCollectionViewCell
code:
class CustomCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var collectionViewButton: UIButton!
}