Search code examples
objective-ciosipaduitableviewdidselectrowatindexpath

didSelectRowAtIndexPath won't fire when moved offscreen


I have a UITableView that is initially offscreen and when a button is pressed, I shift the center point of the view to the right, moving the tableview back on the screen. Similar to the menu in Facebook.

//Slide in Side Menu
[UIView beginAnimations:nil context:nil];    
[UIView setAnimationDuration:.75];

self.view.center = CGPointMake((cgSize.width/2)+10, 165);

[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];    

[UIView commitAnimations];

My problem is that when the top left corner of my tableview is a negative number(off screen) the didSelectRowAtIndexPath will not fire and selection is disabled for some reason.

menuTableView = [[UITableView alloc] initWithFrame:CGRectMake(-350, 0, 350, cgSize.height-50) 
                                                 style:UITableViewStylePlain];

When I change -350 to 0, it works perfectly, like this:

menuTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 350, cgSize.height-50) 
                                                 style:UITableViewStylePlain];

Any ideas?


Solution

  • The table view's frame is outside the view's standard frame, so the input is not being forwarded down to the table view. You need to figure out how to keep the bounds of the table view contained within its parent view, while still animating the way you want it to