Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 次viewController中的MFSideMenu_Objective C_Navigationbar - Fatal编程技术网

Objective c 次viewController中的MFSideMenu

Objective c 次viewController中的MFSideMenu,objective-c,navigationbar,Objective C,Navigationbar,我需要在我的应用程序的所有页面中使用MFSideMenu。现在可以在第一个viewController中工作,但当我在菜单中选择function时,NavigationBar中出现了该按钮,但它不工作 我如何使用这个物体 我加上我所有的.h - (IBAction)showRightMenuPressed:(id)sender; 在我所有的时间里 - (IBAction)showRightMenuPressed:(id)sender { [self.menuContainerV

我需要在我的应用程序的所有页面中使用MFSideMenu。现在可以在第一个viewController中工作,但当我在菜单中选择function时,NavigationBar中出现了该按钮,但它不工作

我如何使用这个物体

我加上我所有的.h

- (IBAction)showRightMenuPressed:(id)sender;
在我所有的时间里

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

MFSideMenuContainerViewController具有类似于leftMenuViewControllercenterViewController等属性。。。您只需将menuviewController作为LeftMenuViewcontroller放置,将navigationController作为centerViewController放置即可

  MenuViewController *VC = [[MenuViewController alloc] init];
  ListViewController *ListVC = [[ListViewController alloc] init];
  TBNavigationController *NavigationVC = [[TBNavigationController alloc] initWithRootViewController:ListVC];

  /*
   Set the NavigationControllers as the ViewControllers of MFSideMenuContainer and make the MFSideMenuContainer as window's rootview.
   */

  MFSideMenuContainerViewController *container = [MFSideMenuContainerViewController
                                                  containerWithCenterViewController:NavigationVC
                                                  leftMenuViewController:VC rightMenuViewController:nil];
  [[AppDelegate appDelegate].window setRootViewController:container];

现在继续向navigationController添加所需数量的VC。

很抱歉,这是我的第二个应用程序,也是我第一次使用此对象。。。我需要在哪里添加此代码?在我的appDelegate中?你也可以用代码最后一行的小技巧将其添加到appDelegate中。在我的appDelegate中,我有以下代码。。。我知道我只需要你代码的最后一行。。但是使用“[self.window setRootViewController:container]不工作…self.window.rootViewController=container;in-didFinishLaunchingWithOptions应该工作不工作!你说我可以在appDelegate中添加此代码…但是…你在哪里添加此代码?在viewDidLoad中的所有viewController中?很抱歉,这是我的第二个应用程序,也是我第一个使用此对象的应用程序…我需要在哪里添加此代码?使用“btnClkSide”“单击uibutton操作时的方法”
-(IBAction)btnClkSide:(id)sender{
    [self.menuContainerViewController toggleLeftSideMenuCompletion:^{
        [self setupMenuBarButtonItems];
    }];
    //    SlideMenuOpem;
}
- (void)setupMenuBarButtonItems {
    self.navigationItem.rightBarButtonItem = [self rightMenuBarButtonItem];
    if(self.menuContainerViewController.menuState == MFSideMenuStateClosed &&
       ![[self.navigationController.viewControllers objectAtIndex:0] isEqual:self]) {
        self.navigationItem.leftBarButtonItem = [self backBarButtonItem];
    } else {
        self.navigationItem.leftBarButtonItem = [self leftMenuBarButtonItem];
    }
}

- (UIBarButtonItem *)leftMenuBarButtonItem {
    return [[UIBarButtonItem alloc]
            initWithImage:[UIImage imageNamed:@"menu-icon.png"] style:UIBarButtonItemStyleBordered
            target:self
            action:@selector(leftSideMenuButtonPressed:)];
}

- (UIBarButtonItem *)rightMenuBarButtonItem {
    return [[UIBarButtonItem alloc]
            initWithImage:[UIImage imageNamed:@"menu-icon.png"] style:UIBarButtonItemStyleBordered
            target:self
            action:@selector(rightSideMenuButtonPressed:)];
}