如何仅将MMDrawerController添加到TabBarController的一个选项卡中?

时间:2017-03-17 09:40:30

标签: ios objective-c uitabbarcontroller tabbarcontroller mmdrawercontroller

我正在使用 Tabbarcontroller ,我想在标签栏的第一个标签页中找到侧边菜单。对于侧边菜单,我正在使用 MMDrawerController

我正在使用故事板

我该怎么办?

1 个答案:

答案 0 :(得分:0)

以下代码对我有用,我在LoginScreen的viewDidload中编写了这段代码,在Storyboard中我创建了LoginScreen作为rootviewController,带有embeded navigationController(表示navigationController是storyboard入口点,LoginScreen是rootViewController)。

UIStoryboard * storyBoard = [UIStoryboard storyboardWithName:@“Main”bundle:nil];         UIViewController * vcSideMenu = [storyBoard instantiateViewControllerWithIdentifier:@“SideMenuScreen”];         UITabBarController * tabBar = [storyBoard instantiateViewControllerWithIdentifier:@“tabBar”];         MMDrawerController * controller = [[MMDrawerController alloc] initWithCenterViewController:tabBar leftDrawerViewController:vcSideMenu rightDrawerViewController:nil];         CGFloat menuWidth = [UIScreen mainScreen] .bounds.size.width * 0.8;         [controller setMaximumLeftDrawerWidth:menuWidth];         [controller setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeNone];         [controller setCloseDrawerGestureModeMask:MMCloseDrawerGestureModeAll];         [self.navigationController pushViewController:controller animated:NO];