Using ECSlidingViewController with TableView
I am using ECSlidingViewController in my application, it contains its own GestureRecognizer
which look like this:
[self.view addGestureRecognizer:self.slidingViewController.panGesture];
And this prevents the TableView from scrolling. When I remove the line scrolling works fine. What's wrong with my approach?
Note: TableView
is part of the navigation controller. And I am using StoryBoards .
source to share
You need to add UIGestureRecognizer
to view UINavigationController
, not to UITableView
.
One way to do this is to create a subclass UINavigationController
that handles the creation of both the gesture recognizer and the creation of your underLeft (or underRight) view controller for the ECSlidingViewController:
// MyNavigationController.h
@interface MyNavigationController : UINavigationController
@end
// MyNavigationController.m
@implementation MyNavigationController
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
if (![self.slidingViewController.underLeftViewController isKindOfClass:[MyLeftMenuViewController class]]) {
self.slidingViewController.underLeftViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"MenuViewController"];
}
[self.view addGestureRecognizer:self.slidingViewController.panGesture];
}
@end
Open the storyboard editor, select the navigation controller, and set the Custom Identity Class Property to a value MyNavigationController
(not the default UINavigationController
).
source to share
I tried the approaches you suggested, but injecting a gesture recognizer inside a UINavigationController subclass didn't work. Ironically, the placement of the theoretically equivalent
[self.navigationController.view addGestureRecognizer:self.slidingViewController.panGesture];
in the TableviewController method viewWillAppear:
does the trick.
source to share