Closing the ECSlidingViewController Menu

I would like to implement my sliding menu in such a way that pressing the "Menu" button will display my menu and press the "Menu" again to hide it. But I cannot figure out how to do this with ECSlidingViewController. Understand any help.

+7
ios ecslidingviewcontroller
source share
3 answers

ECSlidingViewController has methods for doing this: anchorTopViewToRightAnimated: anchorTopViewToLeftAnimated: and resetTopViewAnimated:

An example in your top level controller:

 [self.slidingViewController anchorTopViewToRightAnimated:YES] 

ECSlidingViewController provides a category for the UIViewController that adds this slidingViewController property.

You can also use ECSlidingViewController currentTopViewPosition to determine if your button should show your menu or hide it in the current context.

+10
source share

I came up with this question, and the above answer helps me solve it. But I just need to add a more detailed answer with sample code so that others can benefit from this if they encounter such a problem.

 - (IBAction)showSlidingMenu:(id)sender { [self.slidingViewController anchorTopViewToRightAnimated:YES]; if ([self.slidingViewController currentTopViewPosition] == ECSlidingViewControllerTopViewPositionAnchoredRight) { [self.slidingViewController resetTopViewAnimated:YES]; } } 
  • Note that I am animating the top-level controller to the right, so I am checking to see if the top position of the ECSlidingViewControllerTopViewPositionAnchoredRight position is.
  • Similarly, the top view position has ECSlidingViewControllerTopViewPositionAnchoredLeft if you animate to the left.
  • If the top position is not displayed in the menu, you will get ECSlidingViewControllerTopViewPositionCentered.

+1 for question and accepted answer

Thanks.

+6
source share

According to the “ECSlidingViewController Sample Design”, you need to put these 4 lines in the ViewWillAppear from FirstTopController (e.g. TransitionViewController):

 self.slidingViewController.topViewAnchoredGesture = ECSlidingViewControllerAnchoredGestureTapping | ECSlidingViewControllerAnchoredGesturePanning; self.slidingViewController.customAnchoredGestures = @[]; [self.navigationController.view removeGestureRecognizer:self.dynamicTransitionPanGesture]; [self.navigationController.view addGestureRecognizer:self.slidingViewController.panGesture]; 

These 4 lines are used in the tableview delegate method. Perhaps you are not using tableview so that these 4 rows do not call.

Best of luck ..

0
source share

All Articles