我正在开发具有滑动面板的应用程序(如 facebook 或 google+ 应用程序)。我已经为应用程序的一部分构建了一个主设置菜单。我可以实现任何 github 项目,如 JASidePanels,我遇到的问题是我需要滑动设置菜单出现在应用程序的不同部分,并且滑动设置菜单必须相同。我可以通过为每个 ViewController 构建自己的滑动设置菜单来解决这个问题,但我想问其他人是如何做到这一点的?有没有办法只创建该滑动设置菜单的一个实例并在应用程序的不同部分使用它?
问问题
261 次
1 回答
1
我使用 ZUUIRevealController。
您可以使用它在任何视图控制器上显示您的菜单
我在希望菜单出现的每个视图上都使用这段代码(我正在使用 UINavigationController,但如果需要,您可以修改它以不使用 UINavigationController)。这段代码放在viewDidLoad中
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Back" style: UIBarButtonItemStyleBordered target:nil action:nil];
if ([self.navigationController.parentViewController respondsToSelector:@selector(revealGesture:)] && [self.navigationController.parentViewController respondsToSelector:@selector(revealToggle:)])
{
UIPanGestureRecognizer *navigationBarPanGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self.navigationController.parentViewController action:@selector(revealGesture:)];
[self.navigationController.navigationBar addGestureRecognizer:navigationBarPanGestureRecognizer];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:detail.menuTitle style:UIBarButtonItemStylePlain target:self.navigationController.parentViewController action:@selector(revealToggle:)];
}
编辑- 现在有一个名为 PKRevealController 的新版本已取代 ZUUIRevealController
于 2013-10-21T16:07:11.063 回答