How can I add tag value in sender while creating an UICollectionViewCell? How can I add tag value in sender while creating an UICollectionViewCell? xcode xcode

How can I add tag value in sender while creating an UICollectionViewCell?


You just have it when adding the gesture recognizer to the cell. When the gesture happens, the parameter passed will be the cell. So when declaring the tapGesture method you just access the sender's tag property.

func tapGesture(sender: UITapGestureRecognizer) {    var tag = sender.view!.tag    //do what you want}