How to implement multiple PanGestures (Draggable views)? <p>I want to have several objects that I can drag and drop.</p> <p>Here's my code for moving one object (with lot of help from @vacawama):</p> <pre><code>import UIKit class ViewController: UIViewController { @IBOutlet weak var panView: UIView! @IBOutlet weak var panViewCenterX: NSLayoutConstraint! @IBOutlet weak var panViewCenterY: NSLayoutConstraint! let panRec = UIPanGestureRecognizer() override func viewDidLoad() { super.viewDidLoad() panRec.addTarget(self, action: "draggedView:") panView.addGestureRecognizer(panRec) // Do any additional setup after loading the view, typically from a nib. } func draggedView(sender:UIPanGestureRecognizer){ self.view.bringSubviewToFront(sender.view!) var translation = sender.translationInView(self.view) panViewCenterY.constant += translation.y panViewCenterX.constant += translation.x sender.setTranslation(CGPointZero, inView: self.view) } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } } </code></pre> <p>I want to have more objects in my project:</p> <pre><code> @IBOutlet weak var panView2: UIView! @IBOutlet weak var panView3: UIView! @IBOutlet weak var panView4: UIView! ... </code></pre> <p>So, what is the easiest way to implement this in such way that I can have multiple <code>panView</code> which I can move independently around (one at the time)?</p>