title: Dragging UITableView
body: <p>I'm working on an iPhone application where I want to drag the table view (not the cells) upto a certain point in the screen. I have the tableview sitting in the bottom half of the screen and I have an image in the top-half.</p>
  
  <p>When I scroll the table to see the rows below, the table should actually move up going above the image (y pos decreases and the height will increase). Table will go up until it fills the entire screen leaving a few pixels for the image and it docks there and from that point onwards, the table should scroll. Same behavior is expected for scrolling down as well.</p>
  
  <p>This might sound a little weird but this is a new iOS pattern that's emerging.</p>
  
  <p>I managed to do the first part using the code snippet below.</p>
  
  <pre><code>UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePanForScrollView:)];
  panGestureRecognizer.maximumNumberOfTouches = 1;
  panGestureRecognizer.delegate = self;
  panGestureRecognizer.minimumNumberOfTouches = 1;
  [self.tableView addGestureRecognizer:panGestureRecognizer];
  
  - (void)handlePanForScrollView:(UIPanGestureRecognizer *)gesture {
      switch (gesture.state) {
          case UIGestureRecognizerStateBegan:
              break;
          case UIGestureRecognizerStateChanged: {
  
              CGPoint movement = [gesture translationInView:self.view];
              CGRect frame = self.tableView.frame;
              frame.origin.y += movement.y;
              if(frame.origin.y &gt;= Y_OFFSET &amp;&amp; frame.origin.y &lt; self.original_frame.origin.y){
                  frame.size.height -= movement.y;
                  self.tableView.frame = frame;
                  [gesture setTranslation:CGPointZero inView:self.view];
              }
              break;
          }
          case UIGestureRecognizerStateEnded:
          case UIGestureRecognizerStateCancelled:{
              //NSLog(@"End");
              break;
          }
          default:
              ;
              break;
      }
  }
  </code></pre>
  
  <p>This is working fine and the table moves up and docks below the Y_OFFSET. But as you would have imagined, the table doesn't scroll any more.</p>
  
  <p>So I tried this</p>
  
  <pre><code>- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
  {
      if(self.tableView.frame.origin.y &lt;= Y_OFFSET ||  self.tableView.frame.origin.y &gt;= self.original_frame.origin.y){
          NSLog(@"Here");
          return YES;
      }   
      return NO;
  }
  </code></pre>
  
  <p>"Here" message is getting printed on the console but the table doesn't scroll.</p>
  
  <p>I even tried using the panGestureRecognizer for the UITableView instead of my UIPanGestureRecognizer.</p>
  
  <pre><code>self.tableView.panGestureRecognizer addTarget:self action:@selector(handlePanForScrollView:)
  </code></pre>
  
  <p>But now the table scrolls and moves up. </p>
  
  <p>"I want the table not to scroll but to move until a certain point on the screen and then stop moving and start scrolling."</p>
  
  <p>What's the best way to deal with this ?</p>
  
  <p>Cheers</p>