我希望能够以一种方式实现我的滑动菜单,即按下菜单按钮将显示我的菜单,再次按下菜单将隐藏它。但我无法理解如何使用ECSlidingViewController实现它。感激任何帮助。
我希望能够以一种方式实现我的滑动菜单,即按下菜单按钮将显示我的菜单,再次按下菜单将隐藏它。但我无法理解如何使用ECSlidingViewController实现它。感激任何帮助。
ECSlidingViewController有相应的方法:anchorTopViewToRightAnimated:
、anchorTopViewToLeftAnimated:
和resetTopViewAnimated:
。
示例,您的顶层视图控制器:
[self.slidingViewController anchorTopViewToRightAnimated:YES]
ECSlidingViewController 为 UIViewController 提供一个分类,用于添加 slidingViewController
属性。
您可能还想使用 ECSlidingViewController 的 currentTopViewPosition
来确定您的按钮在当前上下文中是应该显示菜单还是隐藏它。
我想到了这个问题,上面的答案帮助我解决了它。但是我需要添加更详细的答案和代码示例,这样其他人就可以从中受益,如果他们遇到了这样的问题。
- (IBAction)showSlidingMenu:(id)sender {
[self.slidingViewController anchorTopViewToRightAnimated:YES];
if ([self.slidingViewController currentTopViewPosition] == ECSlidingViewControllerTopViewPositionAnchoredRight) {
[self.slidingViewController resetTopViewAnimated:YES];
}
}
self.slidingViewController.topViewAnchoredGesture = ECSlidingViewControllerAnchoredGestureTapping | ECSlidingViewControllerAnchoredGesturePanning;
self.slidingViewController.customAnchoredGestures = @[];
[self.navigationController.view removeGestureRecognizer:self.dynamicTransitionPanGesture];
[self.navigationController.view addGestureRecognizer:self.slidingViewController.panGesture];
这4行代码被用在tableview的代理方法中。如果你没有使用tableview,那么这4行代码就不会被调用。
祝你好运。