0

Working on and iOS app I currently have set up of:

RootViewController hooked up to a UITableViewController via

[self addChildViewController:tableVC];

With the tableVC.view as a subview of the rootViewControllers view. The RootVC then has a UIPanGestureRecognizer which is used to animate a pan left showing the table.

This all works fine and the table is great as a static view, however when you try to fire

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

By tapping on a cell, it is never called. I have already checked if the taps are being accidentally registered by the gesture recogniser but they aren't.

Do I need to somehow tell the RootVC that when the tableView is on screen to send to taps to the child UITableViewController?

BradStevenson
  • 1,974
  • 7
  • 26
  • 40
  • check your UITableView delegate, this is different form the data source. The delegate should be called for this, have you set it? – user387184 Jul 11 '13 at 00:25
  • Yes i have checked the delegate, the exact class for the UITableViewController works fine if initialised as the RootViewController. It only doesn't work when displayed in this way. – BradStevenson Jul 11 '13 at 00:28
  • The answer to your question is no. If you tap on the table view, it should receive the taps just fine. Where do you have didSelectRowAtIndexPath? Which controller is the delegate of the table view? You might try setting RootViewController's view's clipsToBounds property to YES to make sure that your table view is actually within the bounds of that view. – rdelmar Jul 11 '13 at 04:44

1 Answers1

0

Thanks rdelmar for helping me solve this with his advice on using the clipToBounds property of the UITableView's superview.

This showed that the UIViews being revealed through panning werent responding to any touches as they were out of the bounds of their superview.

I solved this by adding another view 'spanView' with the appropriate dimensions to envelope all the subviews. After this they responded to touches as expected.

The hiearchy ended up being:

                         -> leftTableView
RootVC.view - > spanView -> centerView
                         -> rightTableView

Please note that i had to create a subview of RootVC to achieve this as after viewDidLoad iOS set the rootVC.view to the bounds of the devices screen

Community
  • 1
  • 1
BradStevenson
  • 1,974
  • 7
  • 26
  • 40