Answers for "how to perform action on uiimageview in swift"

0

cannot assign IBaction to uiimageview

override func viewDidLoad()
{
    super.viewDidLoad()

    let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(imageTapped(tapGestureRecognizer:)))
    imageView.isUserInteractionEnabled = true
    imageView.addGestureRecognizer(tapGestureRecognizer)
}

@objc func imageTapped(tapGestureRecognizer: UITapGestureRecognizer)
{
    let tappedImage = tapGestureRecognizer.view as! UIImageView

    // Your action
}
Posted by: Guest on February-16-2020

Code answers related to "how to perform action on uiimageview in swift"

Code answers related to "Swift"

Browse Popular Code Answers by Language