I'm trying to add tap event listener on an UIImageView
inside UITableViewCell
so I added an UITapGestureRecognizer
on it and used this code
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
...
cell.editTap.addTarget(self, action: #selector(ProfileTVC.editTapped(sender:)))
//editTap is an UITapGestureRecognizer
...
}
}
func editTapped(sender: UITapGestureRecognizer) {
print("tapped")
if sender.state == UIGestureRecognizerState.ended {
let tapLocation = sender.location(in: self.tableView)
if let tapIndexPath = self.tableView.indexPathForRow(at: tapLocation) {
if fields[tapIndexPath.row].field == "languages_spoken" {
} else if fields[tapIndexPath.row].field == "password" {
} else {
}
}
}
}
but when I'm tapping on my UIImageView
the editTapped
is not being called. Also UIImageView
's user interaction is enabled