title: Swift: which methods are needed to implement a draggable UIImageView?
body: <p>As said in title, I would like the user to be able to drag a UIImageView which serves as pin on a picture and I have followed <a href="http://www.ioscreator.com/tutorials/dragging-views-gestures-tutorial-ios8-swift" rel="nofollow">this</a> tutorial. Here's the class I have written:</p>
  
  <pre><code>import UIKit
  
  class PinImageView: UIImageView {
  
  var lastLocation:CGPoint?
  var panRecognizer:UIPanGestureRecognizer?
  
  init(imageIcon: UIImage?, location:CGPoint) {
      super.init(image: imageIcon)
      self.lastLocation = location
      self.panRecognizer = UIPanGestureRecognizer(target:self, action:"detectPan:")
      self.center = location
      self.gestureRecognizers = [panRecognizer!]
      self.frame = CGRect(x: location.x, y: location.y, width: 20.0, height: 30.0)
  }
  
  required init?(coder aDecoder: NSCoder) {
      fatalError("init(coder:) has not been implemented")
  }
  
  func detectPan(recognizer:UIPanGestureRecognizer) {
      let translation  = recognizer.translationInView(self.superview!)
      self.center = CGPointMake(lastLocation!.x + translation.x, lastLocation!.y + translation.y)
  }
  
  override func touchesBegan(touches: Set&lt;UITouch&gt;, withEvent event: UIEvent?) {
      // Promote the touched view
      self.superview?.bringSubviewToFront(self)
  
      // Remember original location
      lastLocation = self.center
  }
  
  }
  </code></pre>
  
  <p>Those pin <code>UIImageViews</code> should move upon a larger <code>UIImageView</code> which is contained <code>UIViewController</code> where:</p>
  
  <pre><code>class PhotoViewController: UIViewController, UINavigationControllerDelegate, UIImagePickerControllerDelegate {
  
  @IBOutlet weak var imageView: UIImageView!
  var imagePicker: UIImagePickerController!
  var redLocationA:PinImageView = PinImageView(imageIcon: UIImage(named: "pin1.png"), location: CGPointMake(80, 330))
  var redLocationB:PinImageView = PinImageView(imageIcon: UIImage(named: "pin1.png"), location: CGPointMake(80, 360))
  
  override func viewDidLoad() {
      super.viewDidLoad()
      self.view.addSubview(redLocationA)
      self.view.addSubview(redLocationB)
  }
  
  ...
  }
  </code></pre>
  
  <p>When I launch the app everything is correctly showed but the pins do not move if I try to drag them. I am afraid I am missing something...do you know what?
  Maybe the method <code>touchedìsMoved()</code> but it's not mentioned in the tutorial...</p>