简体   繁体   中英

Pan Gesture Not Working With SWRevealViewController

I'm using SWRevealViewController to have a sidebar menu in my iOS app. Both my front and rear view controllers are table view controllers. My front view controller has a bar button item that displays the rear view controller, and I've also enabled the pan gesture to display the rear view controller. The problem is that the pan gesture recognizer works only the first time, but the bar button always launches the rear view controller.

If someone could help me fix it so the pan gesture always worked, that would be great, thanks.

The SWRevealViewController that toggles both views is launched from the storyboard. Here is the code for the front view controller:

- (void)setUpSidebarMenu {

    self.navigationItem.leftBarButtonItem.target = self.revealViewController;
    self.navigationItem.leftBarButtonItem.action = @selector(revealToggle:);
    [self.tableView addGestureRecognizer:self.revealViewController.panGestureRecognizer];
    [self.tableView addGestureRecognizer:self.revealViewController.tapGestureRecognizer];
}

Here is the code for the rear view controller:

- (void)setUpSidebarMenu {

    self.navigationItem.leftBarButtonItem.target = self.revealViewController;
    self.navigationItem.leftBarButtonItem.action = @selector(revealToggle:);
    [self.tableView addGestureRecognizer:self.revealViewController.panGestureRecognizer];
}

Solved, there should be no code in the rear view controller to handle panning, and instead of adding gestures to self.tableView , add them to self.view :

[self.view addGestureRecognizer:self.revealViewController.panGestureRecognizer];
[self.view addGestureRecognizer:self.revealViewController.tapGestureRecognizer];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM