0

I am trying to get the tap gesture to print a line but it keeps coming back with an error that says:

libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)

I have linked the image to the tap outlet and there are no other bad connections.

 override func awakeFromNib() {
    super.awakeFromNib()

    let tap = UITapGestureRecognizer(target: self, action: Selector("likeTapped:"))
        tap.numberOfTapsRequired = 1
    likeImage.addGestureRecognizer(tap)
    likeImage.isUserInteractionEnabled = true

}

 func likeTapped(sender: UITapGestureRecognizer) {
    print("yess called")
}

Has anyone else had this and is there a solution

Tony Merritt
  • 1,177
  • 11
  • 35

1 Answers1

1

was able to fix it thanks to this post.

How to make UITapGestureRecognizer trigger function

I changed my code to this:

  likeImage.isUserInteractionEnabled = true
    let tap = UITapGestureRecognizer(target: self, action: #selector(self.likeTapped(_:)))
        tap.numberOfTapsRequired = 1
    likeImage.addGestureRecognizer(tap)

}

 func likeTapped(_ sender: UITapGestureRecognizer) {
        print("yess called")
    }
Community
  • 1
  • 1
Tony Merritt
  • 1,177
  • 11
  • 35