0

我想在我的项目的右侧添加侧边菜单。我在我的项目中使用 SWRevealViewController 第三方类,在该 RevealToggle 方法对左侧菜单工作正常,但在右侧添加菜单我使用了 rightRevealToggle 方法,该方法不能正常工作。任何建议都会帮助我完成任务。

4

2 回答 2

0

如果您想在 Objective C 中使用右侧菜单,请使用MFSideMenu

在您的 AppDelegate 中:

#import "MFSideMenu.h"

MFSideMenuContainerViewController *container = [MFSideMenuContainerViewController
                                                containerWithCenterViewController:centerViewController
                                                leftMenuViewController:leftMenuViewController
                                                rightMenuViewController:rightMenuViewController];
self.window.rootViewController = container;
[self.window makeKeyAndVisible];

打开和关闭菜单

// toggle the right side menu
[self.menuContainerViewController toggleRightSideMenuCompletion:^{}];
// close the side menu
[self.menuContainerViewController setMenuState:MFSideMenuStateClosed completion:^{}];
// open the right side menu
[self.menuContainerViewController setMenuState:MFSideMenuStateRightMenuOpen completion:^{}];

如果你想使用SWRevealViewController那么可以使用下面的代码。

设置右视图控制器:

@property (strong, nonatomic) UIViewController *rightViewController;
Animated setting of the front view controller:

- (void)pushFrontViewController:(UIViewController *)frontViewController animated:(BOOL)animated;
Animating the position of the front view controller. Position can be: FrontViewPositionLeftSideMostRemoved, FrontViewPositionLeftSideMost, FrontViewPositionLeftSide, FrontViewPositionLeft, FrontViewPositionRight, FrontViewPositionRightMost or FrontViewPositionRightMostRemoved

- (void)setFrontViewPosition:(FrontViewPosition)frontViewPosition animated:(BOOL)animated;
Creating and obtaining a pan gesture recognizer:

- (UIPanGestureRecognizer*)panGestureRecognizer;
Creating and obtaining a tap gesture recognizer:

- (UITapGestureRecognizer*)tapGestureRecognizer;
Other methods are documented in the SWRevealViewController.h header file.
于 2018-05-08T05:55:16.110 回答
0

您正在使用 SWRevealViewController,如果您想在右侧实现菜单,您只需更改您传递给 RevealController 的 ViewControllers

来自 SWRevealViewController 的示例

SWRevealViewController *revealController = [[SWRevealViewController alloc] initWithRearViewController:rearNavigationController frontViewController:frontNavigationController];
revealController.delegate = self;

revealController.rightViewController = YourViewController;

请查看 SWRevealViewController 演示项目中 RevealControllerProject 的 AppDelegate.m。

于 2018-05-08T06:29:18.223 回答