title: Detect swiping in UICollectionView
body: <p>I need to perform a specific action when the user swipes the uicollectionview.
  I built it in a way that each cell captures the full screen.</p>
  
  <p>I tried those ways:</p>
  
  <p><strong>A. scrollViewDidEndDecelerating</strong></p>
  
  <pre><code># pragma UIScrollView
  - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
      NSLog(@"detecting scroll");
      for (UICollectionViewCell *cell in [_servingTimesCollectionView visibleCells]) {
          NSIndexPath *indexPath = [_servingTimesCollectionView indexPathForCell:cell];
          CGPoint scrollVelocity = [scrollView.panGestureRecognizer velocityInView:_servingTimesCollectionView];
          if (scrollVelocity.x &gt; 0.0f)
              NSLog(@"going right");
          else if (scrollVelocity.x &lt; 0.0f)
              NSLog(@"going left");
      }
  }
  </code></pre>
  
  <p>But the <code>scrollVelocity</code> returns null. The method is being called.</p>
  
  <p><strong>B. UISwipeGestureRecognizer</strong></p>
  
  <p>In <code>ViewDidLoad</code> of my <code>UIViewController</code> which delegates to <code>UICollectionViewDataSource</code> and <code>UIGestureRecognizerDelegate</code> I added:</p>
  
  <pre><code>UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(didSwipeRight:)];
  swipeRight.numberOfTouchesRequired = 1;
  [swipeRight setDirection:UISwipeGestureRecognizerDirectionRight];
  
  UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(didSwipeLeft:)];
  swipeRight.numberOfTouchesRequired = 1;
  [swipeRight setDirection:UISwipeGestureRecognizerDirectionRight];
  
  [_servingTimesCollectionView addGestureRecognizer:swipeRight];
  [_servingTimesCollectionView addGestureRecognizer:swipeLeft];
  </code></pre>
  
  <p>and the followings in the UiViewController:</p>
  
  <pre><code>#pragma mark - UISwipeGestureRecognizer Action
  -(void)didSwipeRight: (UISwipeGestureRecognizer*) recognizer {
      NSLog(@"Swiped Right");
  }
  
  -(void)didSwipeLeft: (UISwipeGestureRecognizer*) recognizer {
      NSLog(@"Swiped Left");
  }
  
  - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer     shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
  {
      NSLog(@"Asking permission");
      return YES;
  }
  </code></pre>
  
  <p>But none are called.</p>
  
  <p>What is wrong? I am developing for ios7</p>