-2

I have a UICollectionView and I have template cells that loads from xib file in my collection. however, I am unable to handle the button tapped inside the view that have the UICollectionView. I also want to get the Index of the clicked cell.

I have created the button tapped action in my template cell class but I'm unable to get the index of the cell. How to get it?

Tito
  • 29
  • 8
  • 1
    Possible duplicate of this question here: [enter link description here](https://stackoverflow.com/questions/49059833/how-to-get-the-selected-cell-index-path-swift) – ShaEi Dec 27 '19 at 09:15

1 Answers1

0

You can assign the tag to button in collection view cellforRowAt delegate and in button action use sender.tag to get the index of button.

cell.btnSelect = indexxPath.row

In Button Action

print(sender.tag)