0

I'm using John Lluch's SWRevealViewController in my application and when the sidebar is out and the user wants to close it, the front view is constantly clicked.

What I want to do is disable the front view when the sidebar (Rear view) is shown, but it wasn't as easy as I thought. When disabling the front view (self.revealViewController.frontViewController.view.userInteractionEnabled = NO;), the gesture listener and reveal button listener is also disabled, so the user cannot close the sidebar again.

So have anyone solved a problem similar to this? How can I disable specific components of my view controller? I tried looking through the object and finding the correct subviews but it's just too complex and would be ugly.

Thanks for any input on this!

Joakim
  • 3,224
  • 3
  • 29
  • 53

1 Answers1

2

add SWRevealViewControllerDelegate in your viewcontroller

 SWRevealViewController *revealViewController;

call the following method in view DidLoad

- (void)customSetup
{


revealViewController = self.revealViewController;
revealViewController.delegate=self;

if ( revealViewController )
{

   // revealViewController.toggleAnimationDuration = 0.75;
    [revealViewController panGestureRecognizer];
    [revealViewController tapGestureRecognizer];
   // revealViewController.panGestureRecognizer.enabled = NO;

}

}

add the following method on your settings Button/side bar button

- (IBAction)butBack_actionforMain:(id)sender {

[self hideWaitingHud];



self.navigationController.interactivePopGestureRecognizer.delegate = self;
self.navigationItem.leftBarButtonItem.target = self.revealViewController;
self.navigationItem.leftBarButtonItem.action = @selector(revealToggle:);
[self.revealViewController revealToggle:sender];

// Set the gesture
[self.view addGestureRecognizer:self.revealViewController.panGestureRecognizer];



}

if you want to do something in delegate method

- (void)revealController:(SWRevealViewController *)revealController didMoveToPosition:(FrontViewPosition)position
{
UIWindow *mainWindow = [[UIApplication sharedApplication] keyWindow];

CGPoint windowPoint = [self.view convertPoint:self.view.bounds.origin toView:mainWindow];
NSLog(@"the window position ==%.2f",windowPoint.x);

if (windowPoint.x>0.0)
{
    // set to NO 
    //self.btnHKV.userInteractionEnabled=YES;
    revealViewController.panGestureRecognizer.enabled = NO;
    self.view.userInteractionEnabled = NO;

}
else
{
  // set to YES 
    //self.btnHKV.userInteractionEnabled=YES;
    self.view.userInteractionEnabled = YES;
    revealViewController.panGestureRecognizer.enabled = YES;



 }


}
Anbu.Karthik
  • 82,064
  • 23
  • 174
  • 143