SWRevealViewController how to remove swipe gesture

2020-08-17 05:51发布

问题:

I am using good control SWRevealViewController, but by some redone I want to track my own swipe gestures on my screen. So how can I switch off swipe options? I want to work only revealToggle method that attached to my button. Did someone faced with this? Thank you

回答1:

In order to disable the swipe gesture you can simple do:

self.revealViewController.panGestureRecognizer.enabled=NO;

For example:

-(void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.revealViewController.panGestureRecognizer.enabled=NO;
}

-(void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    self.revealViewController.panGestureRecognizer.enabled=YES;
}


回答2:

In your viewDidLoad method,type the below code where you don't want to enable the swipe gesture:

SWRevealViewController *reveal = self.revealViewController;
reveal.panGestureRecognizer.enabled = NO;


回答3:

I found this method:

for (UIGestureRecognizer *recognizer in self.view.gestureRecognizers) {
    [self removeGestureRecognizer:tap];
}


回答4:

To stop the swipe in the SWRevealViewController:

In Swift 3.0

self.revealViewController().panGestureRecognizer().isEnabled = false