3

I'm using ECSlidingViewController in my application, it contains owns GestureRecognizer that looks like:

[self.view addGestureRecognizer:self.slidingViewController.panGesture];

And it's preventing TableView's scrolling. When I deleted that line scroll works fine. What's wrong with my approach?

Note: TableView is a part of Navigation Controller. And I'm using StoryBoards.

Alex Sharp
  • 533
  • 5
  • 12

3 Answers3

11

You need to add the UIGestureRecognizer to the view of the UINavigationController, not the the UITableView.

One way to do this is to create a UINavigationController subclass that handles the creation of both the gesture recognizer and the instantiation 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 Identity Inspector's Custom Class field to MyNavigationController (rather than the default UINavigationController).

followben
  • 9,067
  • 4
  • 40
  • 42
6

I tried the approaches you suggested,but inserting the gesture recogniser inside a subclass of UINavigationController didn't work. Strangely,placing the theoretically equivalent

[self.navigationController.view addGestureRecognizer:self.slidingViewController.panGesture];

in the TableviewController viewWillAppear: method does the trick instead.

Claus
  • 5,662
  • 10
  • 77
  • 118
0

try

[self.parentView.view addGestureRecognizer:self.slidingViewController.panGesture];

in TableViewController on viewWillAppear