title: Touch underlying view with nextResponder
body: <p>Currently I am trying to recreate the Twitter (iPad) type control. Mostly because all the versions available online are not really working for the type of application I am developing, and I think I can do better of course ;) (but it is harder than I thought).</p>
  
  <p>What I want:</p>
  
  <ul>
  <li>Flexible positioning of the view controllers I add to the control</li>
  <li>No need to change my current view controllers when I want to use them in my control (mainly because I use the view controllers in the iPhone and the iPad version).</li>
  <li>Being able to drag the view controllers around, but still keep al functionality in the view controllers.</li>
  </ul>
  
  <p>What I currently got:</p>
  
  <ul>
  <li>Good positioning on the view controllers, when they are added to my control.</li>
  <li>Able to drag the view controllers around, according to the rules I have set (maximum x position etc)</li>
  </ul>
  
  <p>My problem is that when I add a UITableViewController, I want to be able to drag it around AND keep the functionality of scrolling and selecting cells in the table.</p>
  
  <p>My current solution is, that when a view controller is added to my control, I add a subview to it (with the same size of the view controller) which accepts all the touches. These touches are then send to the control, by using a delegate and calling methods on it. This works well, accept that when I add a subview to my UITableViewController, there is some weird behavior. Scrolling up and down still works in the UITableViewController, but these touches aren't detected by the View on top of the UITableViewController. Selecting cells in the table does not work anymore, because these touches are taken by the overlaying UIView.</p>
  
  <p>I add the overlaying UIView to the UITableViewController like this:</p>
  
  <pre><code>SNOverlayView* layover = [[SNOverlayView alloc] initWithFrame:CGRectMake(0,0, controllerWidth, self.frame.size.height)];
  layover.delegate = self;
  [controller.view addSubview:layover];
  [layover release];
  </code></pre>
  
  <p>My custom overlay UIView contains a couple of these methods, for all the touch (began, ended, cancelled and moved) methods:</p>
  
  <pre><code>- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
  {
  if ([delegate respondsToSelector:@selector(overlayTouchesBegan:touches:event:)])
      [delegate overlayTouchesBegan:self touches:touches event:event];
  
      NSLog(@"%@", self.nextResponder);   
  
      [self.nextResponder touchesBegan:touches withEvent:event];
  }
  </code></pre>
  
  <p>From what I understand from the documentation, the call to the nextResponder, should make sure that the TableView below my view also receives the touches. But these methods only get triggered when I touch the screen once OR slide sideways. Sliding from up to down does not trigger these methods and touching a cell does not trigger the didSelectRowAtIndexPath from the UITableViewController. The self.nextResponder in this method is a UITableView (which is outputted by the NSLog in that method).</p>
  
  <p>I am misunderstanding the nextResponder part? Isn't this possible when not modifying my UITableViewController? </p>
  
  <p><strong>EDIT:</strong> I updated the structure which I add to my main UIView containing all ViewControllers:</p>
  
  <pre><code>|- Root UIView (1)
  |-- Containment UIView which detects touches (2)
  |---- UITableViewController (3)
  </code></pre>
  
  <p>The problem is that now my containment view (2) does not detect touches. I will try to update my code to make it more like the structure mentioned below:</p>
  
  <pre><code>|- Root UIView (1)
  |-- Containment UIView (2)
  |---- UIView detecting touches (4)
  |---- UITableViewController  (3)
  </code></pre>
  
  <p>But I am not sure how I can get the UIView to detect touches. because when I add the UITableViewcontroller (3) to my containment UIView (2) it will be put on top of the UIView detecting the touches (4) and therefor 'stealing' the touches. I would rather change the order of (4) and (3).</p>