0

I am implementing ECSlidingViewController in my app. Everything works fine, when I hit the menu button (UIBar) the left menu slides. But pressing the menu button again does not bring back the current ViewController.

It works in the sample app, but I cannot find that line of code that brings back the current controller.

Here is the code to show the menu:

- (IBAction)menuButtonTapped:(id)sender {
    [self.slidingViewController anchorTopViewToRightAnimated:YES];
}

Now I am looked everywhere for the part of the code that can dismiss the left menu layout but could not find it. It must be burry somewhere...

Github project

How do you get back to the current View Controller by pressing the Menu UIBar button ?


@Eric opened my eyes on what is performing that event. It seems like the UIPanGestureRecognizer is the one responsible to redisplay the main screen, unfortunately I couldnt get it to work after implementing that deleguate.

- (UIPanGestureRecognizer *)dynamicTransitionPanGesture {
    if (_dynamicTransitionPanGesture) return _dynamicTransitionPanGesture;

    _dynamicTransitionPanGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self.transitions.dynamicTransition action:@selector(handlePanGesture:)];

    return _dynamicTransitionPanGesture;
}
Community
  • 1
  • 1
  • resetTopView is the method that actually brings back the main view. Why your implementation is not doing that automatically can't be determined without code. Setting the property resetStrategy decides if tap will automatically reset the view – Eric Mar 10 '14 at 18:48
  • How is it attached to the UIBar item, because it is not obvious in XCode, basically I am copy pasting pieces from the sample app, I just did not see that part –  Mar 10 '14 at 18:53
  • Your main view with the UIBar item is actually a screen shot of that page. That screen shot has a UITapGestureRecognizer on it if you so choose which makes clicking anywhere over there dismiss the view. If the way you have it set up actually allows you to press the bar button (and see it being pressed), then just add [self.slidingViewController resetTopView] in it's IBAction – Eric Mar 10 '14 at 19:04
  • You know what that make sense, I just realized it wasnt the actual UIBar item, but the gesture it self, I implemented `UITapGestureRecognizer` however my issue remain. I edited my post.. –  Mar 10 '14 at 19:28

2 Answers2

1

You are probably looking for the following line:

self.slidingViewController.topViewAnchoredGesture = ECSlidingViewControllerAnchoredGestureTapping | ECSlidingViewControllerAnchoredGesturePanning;

in METransitionsViewController.m in the example TransitionFun project.

This controls how the Top View behaves to gestures while it is anchored to the side. You can refer to Anchored Top Views Gesture for more info.

sigabrt
  • 1,047
  • 8
  • 11
0

As @eric pointed out, the UIBar button only displays the menu.

If you want it to dismiss the menu on the same IBAction you will need to add more logic:

- (IBAction)menuButtonTapped:(id)sender {
   //Chek the current position
   if([self.slidingViewController currentTopViewPosition]==2){
      //show menu
      [self.slidingViewController anchorTopViewToRightAnimated:YES];
   }else{
      //Dismiss menu
      [self.slidingViewController resetTopViewAnimated:YES];
   }
}
meda
  • 45,103
  • 14
  • 92
  • 122