我想在项目的右侧添加侧边菜单。我现在在我的项目中使用SWRevealViewController第三方类,因为revealToggle方法对于左侧菜单工作正常,但是在右侧添加菜单我使用了rightRevealToggle方法,该方法工作不正常。任何建议都将帮助我完成任务。
答案 0 :(得分: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.
答案 1 :(得分:0)
您正在使用SWRevealViewController,如果您想在右侧实现菜单,您只需要更改传递给revealController的ViewControllers
来自SWRevealViewController的示例
SWRevealViewController *revealController = [[SWRevealViewController alloc] initWithRearViewController:rearNavigationController frontViewController:frontNavigationController];
revealController.delegate = self;
revealController.rightViewController = YourViewController;
请在演示中查看RevealControllerProject的AppDelegate.m SWRevealViewController项目。