0

我正在ECSlidingViewController我的应用程序中实施。一切正常,当我点击菜单按钮(UIBar)时,左侧菜单滑动。但再次按下菜单按钮不会恢复当前的ViewController.

它在示例应用程序中工作,但我找不到带回当前控制器的代码行。

这是显示菜单的代码:

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

现在我到处寻找可以关闭左侧菜单布局但找不到它的代码部分。一定是埋在什么地方……

Github 项目

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


@Eric 让我看到了正在执行该事件的内容。似乎UIPanGestureRecognizer是负责重新显示主屏幕的人,不幸的是,在实施该代表后我无法让它工作。

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

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

    return _dynamicTransitionPanGesture;
}
4

2 回答 2

1

您可能正在寻找以下行:

self.slidingViewController.topViewAnchoredGesture = ECSlidingViewControllerAnchoredGestureTapping | ECSlidingViewControllerAnchoredGesturePanning;

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

这控制了顶视图在锚定到侧面时对手势的行为方式。您可以参考锚定顶视图手势了解更多信息。

于 2014-07-14T17:22:25.073 回答
0

正如@eric 指出的那样,该UIBar按钮仅显示菜单。

如果您希望它关闭同一 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];
   }
}
于 2014-03-10T20:18:50.860 回答