我正试图创建一个MFSideMenu,但我从未使用过它,也不知道它缺少什么。有人能写一个关于如何完成它的简短教程吗?
-(void)viewDidLoad{
MFSideMenuContainerViewController *container = [MFSideMenuContainerViewController
containerWithCenterViewController:centerViewController
leftMenuViewController:leftMenuViewController
rightMenuViewController:rightMenuViewController];
self.window.rootViewController = container;
[self.window makeKeyAndVisible];
}
在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;
}
将此代码放入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;
}