UIImageView Recognizer

Solutions Collect From Internet About “UIImageView Recognizer”

I would add a gestureRecognizer to each imageView. The function called by the gestureRecognizer would then change the image on the “big picker view”. There is no built-in way to get the image name that the user chose. If you really needed this, then you could sublcass UIImageView and add a fileName property.

@IBOutlet var imageView: UIImageView!
@IBOutlet var bigPickerImageView: UIImageView!

override func viewDidLoad() {

    // create tap gesture recognizer
    let tapGesture = UITapGestureRecognizer(target: self, action: "tapGesture:")

    // add it to the image view;
    // make sure imageView can be interacted with by user
    imageView.userInteractionEnabled = true        

func tapGesture(gesture: UIGestureRecognizer) {
    // if the tapped view is a UIImageView then set it to imageview
    if let imageView = gesture.view as? UIImageView {  // if you subclass UIImageView, then change "UIImageView" to your subclass
        // change the image on the bigPickerImageView
        bigPickerImageView.image = imageView.image
        // if you subclass UIImageView, then you could get the filename here.