Cruelty gesture not detected in UITableViewCell

I am trying to detect a click gesture on a UIImageView inside a UITableViewCell.

This is part of the code inside cellForRowAtIndexPath:

let cell1 : cellTableViewCell = self.tableView.dequeueReusableCellWithIdentifier("cell") as! cellTableViewCell


        tableView.allowsSelection = false
        cell1.profileImg.userInteractionEnabled = true

        let tappedOnImage = UIGestureRecognizer(target: cell1, action: "tappedOnImage:")

        cell1.profileImg.tag = indexPath.row
        cell1.profileImg.addGestureRecognizer(tappedOnImage)

And here is the function that processes the gesture:

func tappedOnImage(sender:UITapGestureRecognizer){


    print("hey")
}

However, nothing happens when I use any suggestions?

+4
source share
1 answer

It's hard to say what's wrong without seeing more code, but try the following:

let tappedOnImage = UITapGestureRecognizer(target: self, action: "tappedOnImage:")
+1
source

Source: https://habr.com/ru/post/1611340/


All Articles