title: Pan Gesture in UICollectionViewCell AND UICollectionView
body: <p>I have a collection view of bars that can slide up and down. Each cell in the collection view is using a <code>UIPanGestureRecognizer</code> to control the blue bar sliding up and down. The collection view does not scroll here.</p>
  
  <p><img src="https://i.stack.imgur.com/aiNPy.png" alt="Active"></p>
  
  <p>There is an "edit mode" which disables the pan gesture controlling the bars. The hope here is that in "edit mode", the collection view can then scroll left and right. </p>
  
  <p><img src="https://i.stack.imgur.com/Ts89p.png" alt="Edit Mode"></p>
  
  <p>My attempt at doing this was to disabled the pan gesture in each of the cells. I also tried using the <code>UIGestureRecognizerDelegate</code> methods to try to disable touches and fail the cell's pan gesture in favor of the collection view's pan gesture. It seems that the collection view's pan gesture is not forwarded to any of the cell's gesture delegate calls.</p>
  
  <p>These delegate calls got me the closest (delegate for cell's pan gesture):</p>
  
  <pre><code>func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWithGestureRecognizer otherGestureRecognizer: UIGestureRecognizer) -&gt; Bool {
      return true
  }
  
  func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldReceiveTouch touch: UITouch) -&gt; Bool {
      return !self.editMode  // bar doesn't need to pan in edit mode
  }
  </code></pre>
  
  <p>With this implemented, I could pan the collection view if I started the pan in the white space between cells. Starting a pan on a cell would not do anything, though.</p>
  
  <p>EDIT: I uploaded a <a href="https://github.com/keithbhunter/CollectionViewIssues" rel="nofollow noreferrer">sample project</a> of the issue to github.</p>