title: Subclass UIScrollView in Swift for touches Began & touches Moved
body: <p><img src="https://i.stack.imgur.com/Yw5ht.png" alt="enter image description here">I'm using Swift 1.2</p>
  
  <p>I'm trying to use this <a href="https://stackoverflow.com/questions/6660327/uiscrollview-touchesbegan-touchesmoved-touchesended-actions">UIScrollview touchesbegan,touchesmoved,touchesended actions</a> and the link in the 2nd comment of the accepted answer. </p>
  
  <p>I'm using a storyboard with auto layout, I set my custom class for the UIScrollView in Custom Class. </p>
  
  <p>I'm not receiving either of these touch events in the UIViewController that contains my custom UIScrollView</p>
  
  <p><strong>Edit: Updated my code for how I use it with @Victor Sigler 's answer.</strong></p>
  
  <p>Custom ScrollView Code:</p>
  
  <pre><code>import UIKit
  
  protocol PassTouchesScrollViewDelegate {
  
  func scrollTouchBegan(touches: Set&lt;NSObject&gt;, withEvent event: UIEvent)
  func scrollTouchMoved(touches: Set&lt;NSObject&gt;, withEvent event: UIEvent)
  }
  
  class PassTouchesScrollView: UIScrollView {
  
  var delegatePass : PassTouchesScrollViewDelegate?
  
  override init(frame: CGRect) {
      super.init(frame: frame)
  }
  
  required init(coder aDecoder: NSCoder) {
      super.init(coder: aDecoder)
  }
  
  override func touchesBegan(touches: Set&lt;NSObject&gt;, withEvent event: UIEvent) {
  
      self.delegatePass?.scrollTouchBegan(touches, withEvent: event)
  
  
  }
  
  override func touchesMoved(touches: Set&lt;NSObject&gt;, withEvent event: UIEvent) {
  
      self.delegatePass?.scrollTouchMoved(touches, withEvent: event)
  
  }
  
  }
  </code></pre>
  
  <p>My ViewController: </p>
  
  <pre><code>import UIKit
  
  class ViewController: UIViewController, PassTouchesScrollViewDelegate {
  
  @IBOutlet weak var scrollView: UIScrollView!
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
      scrollView.delegatePass = self
  }
  
  func scrollTouchBegan(touches: Set&lt;NSObject&gt;, withEvent event: UIEvent)    {
  
      println("began \(touches)")
  
  }
  
  func scrollTouchMoved(touches: Set&lt;NSObject&gt;, withEvent event: UIEvent)      {
  
      println("moved \(touches)")
  }     
  
  }
  </code></pre>
  
  <p>I'm trying to let a user draw a line over a UIImage, which I got working using a PanGesture Recognizer but the performance was very poor, especially on older hardware, I followed a Ray Wenderlich tutorial that used touches Began and the performance was much better, however it was on a UIView and not a ScrollView. I need a UIScrollView since prior to a user drawing on an image they can zoom in and around it. </p>