This may seem really simple, but I've been tearing my hair out for a while now wondering why this isn't working. I'm trying to change the image when tapped on, but it doesn't seem to recognise the tap at all. I have enabled user interaction both on the storyboard and programatically, so am a little lost.
override func viewDidLoad() {
super.viewDidLoad()
tL.isUserInteractionEnabled = true
x = UIImage(named: "Cross.jpg")
reset = UIImage(named: "white.png")
//Tap Gesture ------------------------------------------------------------
let gestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(Logic))
gestureRecognizer.numberOfTapsRequired = 1
tL.addGestureRecognizer(gestureRecognizer)
}
func Logic(_ sender: UITapGestureRecognizer) {
let tappedView = sender.view as! UIImageView
tappedView.image = x
print("Image Tapped")
}