如何返回到当前的视图控制器?

我在我的应用程序中实现ECSlidingViewController 。 一切正常,当我点击菜单button(UIBar)的左侧菜单滑动。 但再次按下菜单button不会返回当前的ViewController

它在示例应用程序中起作用,但是我无法find返回当前控制器的那一行代码。

这里是显示菜单的代码:

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

现在我到处寻找可以closures左侧菜单布局但是找不到它的代码部分。 它必须在某处埋葬…

Github项目

如何通过按菜单UIBarbutton回到当前的视图控制器?


@Eric打开了我的眼睛,看看正在进行的事件。 看起来UIPanGestureRecognizer是一个负责重新显示主屏幕的人,不幸的是,在实现这个删除操作之后,我无法让它工作。

 - (UIPanGestureRecognizer *)dynamicTransitionPanGesture { if (_dynamicTransitionPanGesture) return _dynamicTransitionPanGesture; _dynamicTransitionPanGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self.transitions.dynamicTransition action:@selector(handlePanGesture:)]; return _dynamicTransitionPanGesture; } 

正如@eric指出的, UIBarbutton只显示菜单。

如果你想要closures同一个IBAction的菜单,你将需要添加更多的逻辑:

 - (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]; } } 

您可能正在寻找以下行:

 self.slidingViewController.topViewAnchoredGesture = ECSlidingViewControllerAnchoredGestureTapping | ECSlidingViewControllerAnchoredGesturePanning; 

在例子TransitionFun项目的METransitionsViewController.m中。

这控制了俯视图在锚定到一边时如何进行手势。 你可以参考锚定顶视图手势更多的信息。