3

How do you programmatically disable the SWRevealViewController swipe in a single UIViewController while allowing it to work in all the others?

I want to disable the SWRevealViewController in my login view controller so users cannot bypass it using the menu.

Currently, users can swipe to reveal the menu, and then choose an item that goes to another view controller. I want to disable this.

Ray White
  • 264
  • 3
  • 16
  • I think a better solution for your specific problem (avoiding the menu on the login screen) would be to place the SWRevealViewController after the login screen. On my answer to my own question on SO (http://stackoverflow.com/questions/35022296/how-do-i-use-swrevealviewcontroller-with-unwind-segues) I have a storyboard showing how to obtain exactly that. – Felipe Ferri Feb 06 '16 at 11:31

2 Answers2

9

You just want to disable the pan gesture for the particular view.

Like this:

SWRevealViewController *reveal = self.revealViewController;
reveal.panGestureRecognizer.enabled = NO;
Hiren
  • 648
  • 7
  • 19
0

I ended up using a variable that forced the same UIViewController back to the front when any menu item was selected. (This happened to be a login page.) Here is the code I used.

This forced my login page to be the active one, even if another menu item was chosen. The only way to get out was to enter the username and password.

So technically, I did not disable the swipe, but this also works.

Boolean bForceLogin = getMySettingFromDatabase;
if (bForceLogin)
{
    UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil];
    UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"loginviewcontroller"];
    [revealController setFrontViewController:vc animated:YES];
    return;
}
Ray White
  • 264
  • 3
  • 16