Reputation: 1088
I'm trying to detect a tap gesture on a UIImageView inside a UITableViewCell.
This is the 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's the function handling the gesture:
func tappedOnImage(sender:UITapGestureRecognizer){
print("hey")
}
However, nothing is happening when I tap.. any suggestions?
Upvotes: 4
Views: 3166
Reputation: 38
It is hard to tell what is wrong without seeing more code, but try this:
let tappedOnImage = UITapGestureRecognizer(target: self, action: "tappedOnImage:")
Upvotes: 1