我如何使用 MFSideMenu?

how I use MFSideMenu?

我正在尝试创建一个 MFSideMenu,但我从未使用过它,也不知道它缺少什么。任何人都可以写一个关于如何完成它的简短教程吗?

-(void)viewDidLoad{

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

将此代码放入您的 AppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];


    // init center, left, and right view controllers

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



    return YES;
}

在AppDelegate.h

#import "MFSideMenuContainerViewController.h"

在AppDelegate.m

MFSideMenuContainerViewController *container = (MFSideMenuContainerViewController *)self.window.rootViewController;

    UINavigationController *navigationController = [self.storyboard instantiateViewControllerWithIdentifier:@"navigationController"];  //I have instantiated using storyboard id. 
    UIViewController *leftSideMenuViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"sideMenuViewController"];   //I have instantiated using storyboard id. 

    [container setLeftMenuViewController:leftSideMenuViewController];
    [container setCenterViewController:navigationController];

在您的 controller.m 添加:

- (IBAction)menuPressed:(id)sender
{
     [self.menuContainerViewController toggleLeftSideMenuCompletion:nil];
}

- (MFSideMenuContainerViewController *)menuContainerViewController
 {
 return  (MFSideMenuContainerViewController*)self.navigationController.parentViewController;
}