Reputation: 602
i have 2 custom cell which singleCell and doubleCell. I want to know which one selected when didSelectItemAt method trigered.
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
if singleSelected {
print("SINGLE CELL SELECTED)
} else {
print("DOUBLE CELL SELECTED)
}
}
Thanks.
Upvotes: 0
Views: 98
Reputation: 38833
You can do it by checking the cellForItem
in your didSelectItemAt
function:
if let singleCell = collectionView.cellForItem(at: indexPath) as? SingleCell {
// singleCell selected
} else {
// doubleCell selected
}
Upvotes: 1