title: Using UITouch inside UITableviewscell, Touchbegan not working
body: <p>I am using <a href="https://github.com/johankasperi/SwiftHSVColorPicker" rel="nofollow noreferrer">this</a> library for colorpicker and I have added this inside the subview of UITableviewcell, </p>
  
  <p>here the problem is when I began moving the color indicatioror change the HUE level slider  inside cell  its Scrolling UITableView as well. </p>
  
  <p>what I am currently doing now is, added 2 functions in TableViewScrollDelegate</p>
  
  <pre><code>protocol BrightnessViewDelegate: class {
   func brightnessSelected(_ brightness: CGFloat)
  }
  
  protocol TableViewScrollDelegate: class {
    func tableViewScrollStart()
    func tableViewScrollPause()
  }
  
  class BrightnessView: UIView {
  
  weak var delegate: BrightnessViewDelegate?
  weak var delegateScroll: TableViewScrollDelegate?
  var colorLayer: CAGradientLayer!
  
  var point: CGPoint!
  var indicator = CAShapeLayer()
  var indicatorColor: CGColor = UIColor.lightGray().cgColor
  var indicatorBorderWidth: CGFloat = 2.0
  
  init(frame: CGRect, color: UIColor) {
      super.init(frame: frame)
  
      // Init the point at the correct position
      point = getPointFromColor(color)
  
      // Clear the background
      backgroundColor = UIColor.clear()
  
      // Create a gradient layer that goes from black to white
      // Create a gradient layer that goes from black to white
      var hue: CGFloat = 0.0, saturation: CGFloat = 0.0, brightness: CGFloat = 0.0, alpha: CGFloat = 0.0
      let ok: Bool = color.getHue(&amp;hue, saturation: &amp;saturation, brightness: &amp;brightness, alpha: &amp;alpha)
      if (!ok) {
          print("SwiftHSVColorPicker: exception &lt;The color provided to SwiftHSVColorPicker is not convertible to HSV&gt;")
      }
      colorLayer = CAGradientLayer()
      colorLayer.colors = [
          UIColor.white().cgColor,
          UIColor(hue: hue, saturation: saturation, brightness: 1, alpha: 1).cgColor
      ]
      colorLayer.locations = [0.0, 1.0]
      colorLayer.startPoint = CGPoint(x: 0.0, y: 0.5)
      colorLayer.endPoint = CGPoint(x: 1.0, y: 0.5)
      colorLayer.frame = CGRect(x: 0, y: 2, width: self.frame.size.width, height: 24)
      // Insert the colorLayer into this views layer as a sublayer
      self.layer.insertSublayer(colorLayer, below: layer)
  
      // Add the indicator
      indicator.strokeColor = indicatorColor
      indicator.fillColor = indicatorColor
      indicator.lineWidth = indicatorBorderWidth
      self.layer.addSublayer(indicator)
  
      drawIndicator()
  }
  
  required init?(coder aDecoder: NSCoder) {
      super.init(coder: aDecoder)
  }
  
  override func touchesBegan(_ touches: Set&lt;UITouch&gt;, with event: UIEvent?) {
      delegateScroll?.tableViewScrollPause()
      touchHandler(touches)
  }
  override func touchesEnded(_ touches: Set&lt;UITouch&gt;, with event: UIEvent?) {
      delegateScroll?.tableViewScrollStart()
  }
  
  override func touchesMoved(_ touches: Set&lt;UITouch&gt;, with event: UIEvent?) {
      touchHandler(touches)
  }
  
  func touchHandler(_ touches: Set&lt;UITouch&gt;) {
      // Set reference to the location of the touchesMoved in member point
      if let touch = touches.first {
          point = touch.location(in: self)
      }
  
      point.y = self.frame.height/2
      point.x = getXCoordinate(point.x)
      // Notify delegate of the new brightness
      delegate?.brightnessSelected(getBrightnessFromPoint())
  
      drawIndicator()
  }
  
  func getXCoordinate(_ coord: CGFloat) -&gt; CGFloat {
      // Offset the x coordinate to fit the view
      if (coord &lt; 1) {
          return 1
      }
      if (coord &gt; frame.size.width - 1 ) {
          return frame.size.width - 1
      }
      return coord
  }
  
  func drawIndicator() {
      // Draw the indicator
      if (point != nil) {
          indicator.path = UIBezierPath(roundedRect: CGRect(x: point.x-3, y: 0, width: 6, height: 28), cornerRadius: 3).cgPath
      }
  }
  
  func getBrightnessFromPoint() -&gt; CGFloat {
      // Get the brightness value for a given point
      return point.x/self.frame.width
  }
  
  func getPointFromColor(_ color: UIColor) -&gt; CGPoint {
      // Update the indicator position for a given color
      var hue: CGFloat = 0.0, saturation: CGFloat = 0.0, brightness: CGFloat = 0.0, alpha: CGFloat = 0.0
      let ok: Bool = color.getHue(&amp;hue, saturation: &amp;saturation, brightness: &amp;brightness, alpha: &amp;alpha)
      if (!ok) {
          print("SwiftHSVColorPicker: exception &lt;The color provided to SwiftHSVColorPicker is not convertible to HSV&gt;")
      }
  
      return CGPoint(x: brightness * frame.width, y: frame.height / 2)
  }
  
  func setViewColor(_ color: UIColor!) {
      // Update the Gradient Layer with a given color
      var hue: CGFloat = 0.0, saturation: CGFloat = 0.0, brightness: CGFloat = 0.0, alpha: CGFloat = 0.0
      let ok: Bool = color.getHue(&amp;hue, saturation: &amp;saturation, brightness: &amp;brightness, alpha: &amp;alpha)
      if (!ok) {
          print("SwiftHSVColorPicker: exception &lt;The color provided to SwiftHSVColorPicker is not convertible to HSV&gt;")
      }
      colorLayer.colors = [
          UIColor.white().cgColor,
          UIColor(hue: hue, saturation: saturation, brightness: 1, alpha: 1).cgColor
      ]
  }
  }
  </code></pre>
  
  <blockquote>
    <p>My ViewController with Tableview</p>
  </blockquote>
  
  <pre><code> func tableViewScrollStart() {
      self.tableView.isScrollEnabled = true
  }
  
  func tableViewScrollPause() {
      self.tableView.isScrollEnabled = false
  }
  </code></pre>
  
  <p>I dont want tableview to scroll when I am changing color in this cell.</p>
  
  <p>Hope I am able to explain my question clearly.</p>
  
  <p>Thank you</p>