像Facebook一样滑动菜单

时间:2014-01-20 11:39:36

标签: ios iphone uisplitviewcontroller

大家好!

我已经使用MFSideMenuContainerViewController在我的某个应用中实现了像fb这样的幻灯片菜单。这给了我来自Appdelegate的幻灯片视图,因为我使用以下内容集成了它:

    // allocate side viewcontroller
    SideMenuViewController *leftMenuViewController = [[[SideMenuViewController alloc] initWithStyle:UITableViewStyleGrouped] autorelease];
  //  leftMenuViewController.view.hidden = NO;
    // allocate menuview to open sideview
    MFSideMenuContainerViewController *container = [MFSideMenuContainerViewController containerWithCenterViewController:[self navigationController] leftMenuViewController:leftMenuViewController rightMenuViewController:nil] ;
 //   [container setMenuState:MFSideMenuStateLeftMenuOpen];
    // assign menu view as a root view for window
    **self.window.rootViewController = container;**

现在我想实现这个幻灯片视图,但不是来自RootView。 我有 **launch image -> ViewController -> detailViewController**

所以我希望我的侧视图在detailViewController中。如何使用MFSideMenuContainerViewController实现此目的?

我尝试了以下

    // allocate side viewcontroller
    SideMenuViewController *leftMenuViewController = [[[SideMenuViewController alloc] initWithStyle:UITableViewStyleGrouped] autorelease];
  //  leftMenuViewController.view.hidden = NO;
    // allocate menuview to open sideview
    MFSideMenuContainerViewController *container = [MFSideMenuContainerViewController containerWithCenterViewController:<my ViewController> leftMenuViewController:leftMenuViewController rightMenuViewController:nil] ;
 //   [container setMenuState:MFSideMenuStateLeftMenuOpen];
    // assign menu view as a root view for window
    **[self.navigationController pushViewController:vc animated:YES];**

但是这会给出带有侧边菜单的空白屏幕。

任何帮助都一如既往地受到高度赞赏! 谢谢&amp;此致

2 个答案:

答案 0 :(得分:1)

只需按下它就像从另一个视图控制器推送一个新的视图控制器一样。

[container presentViewController:<my ViewController> animated:yes completion:nil];

[[self navigationController] pushviewcontroller:myController];

答案 1 :(得分:0)

试试这对你有帮助

SplashViewController *splashObj = [[SplashViewController alloc] initWithNibName:@"SplashViewController" bundle:nil];
    self.navigationController = [[UINavigationController alloc] initWithRootViewController:splashObj];

MainMenuVC *leftViewController = [[MainMenuVC alloc] initWithNibName:@"MainMenuVC" bundle:nil];
MFSideMenuContainerViewController *container = [MFSideMenuContainerViewController containerWithCenterViewController:self.navigationController
                                                          leftMenuViewController:leftViewController
                                                         rightMenuViewController:leftViewController];
container.panMode = MFSideMenuPanModeNone;
self.window.rootViewController = container;