10

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

Matrosov Oleksandr
  • 25,505
  • 44
  • 151
  • 277

4 Answers4

17

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;
}
matteolel
  • 519
  • 4
  • 14
  • self.revealViewController().panGestureRecognizer().isEnabled=false, worked for me in Swift 4.2 – Ravi Oct 04 '18 at 05:48
10

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;
Hiren
  • 676
  • 7
  • 21
1

I found this method:

for (UIGestureRecognizer *recognizer in self.view.gestureRecognizers) {
    [self removeGestureRecognizer:tap];
}
Matrosov Oleksandr
  • 25,505
  • 44
  • 151
  • 277
1

To stop the swipe in the SWRevealViewController:

In Swift 3.0

self.revealViewController().panGestureRecognizer().isEnabled = false
Ramakrishna
  • 712
  • 8
  • 26