使用侧面板实现 UITabbarcontroller 的最佳方法是什么?

What is the best way to implement UITabbarcontroller with sidepanel?

我想使用 uitabbarcontroller 实现侧边栏(抽屉)。我已经使用 lib JASidePanel 为 uiviewcontroller 实现了。但我没有找到任何方法来实现 uitabarcontroller。

感谢帮助

我正在将 MMDrawerController 与 TabBar 一起用作侧边栏。

这是我初始化MMDrawer和tabBar的代码

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

[[MMExampleDrawerVisualStateManager sharedManager] setRightDrawerAnimationType:MMDrawerAnimationTypeParallax];

self.tabbarController = [[UITabBarController alloc] init];
self.tabbarController.delegate = self;

JSIntroViewController *obj_loginViewController = [[JSIntroViewController alloc] initWithNibName:@"JSIntroViewController" bundle:nil];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:obj_loginViewController];
self.navigationController.navigationBarHidden = YES;    

[self initializeTabBarControllerwithAnimation:FALSE];


UIViewController *rightViewController = [[JSMenuViewController alloc] init];

self.drawerController = [[MMDrawerController alloc]
                         initWithCenterViewController:self.navigationController
                         leftDrawerViewController:nil
                         rightDrawerViewController:rightViewController];
[self.drawerController setShowsShadow:NO];
[self.drawerController setRestorationIdentifier:@"MMDrawer"];
[self.drawerController setMaximumRightDrawerWidth:[UIScreen mainScreen].bounds.size.width-65];

[self.drawerController setGestureShouldRecognizeTouchBlock:^BOOL(MMDrawerController *drawerController, UIGestureRecognizer *gesture, UITouch *touch) {
    if([gesture isKindOfClass:[UITapGestureRecognizer class]])
        return YES;
    return NO;
}];
[self.drawerController
 setDrawerVisualStateBlock:^(MMDrawerController *drawerControllerr, MMDrawerSide drawerSide, CGFloat percentVisible) {
     MMDrawerControllerDrawerVisualStateBlock block;
     block = [[MMExampleDrawerVisualStateManager sharedManager]
              drawerVisualStateBlockForDrawerSide:drawerSide];
     if(block)
         block(drawerControllerr, drawerSide, percentVisible);
         }];
}

这是我初始化tabBar的方法。

- (void)initializeTabBarControllerwithAnimation:(BOOL)animation
{
//First tab as Browse Job
JSBrowseViewController *obj_browseViewController =   [[JSBrowseViewController alloc] initWithNibName:@"JSBrowseViewController" bundle:nil];
//BrowseViewController *obj_browseViewController = [[BrowseViewController alloc] initWithNibName:@"BrowseViewController" bundle:nil];
UINavigationController *navi1 = [[UINavigationController alloc] initWithRootViewController:obj_browseViewController];
    navi1.navigationBar.translucent = NO;

//Second tab as Liked Job
LikedViewController *obj_likedViewController = [[LikedViewController alloc] initWithNibName:@"LikedViewController" bundle:nil];
UINavigationController *navi2 = [[UINavigationController alloc] initWithRootViewController:obj_likedViewController];
navi2.navigationBar.translucent = NO;

[self.tabbarController setViewControllers:[NSArray arrayWithObjects:navi1, navi2, nil]];
[self.tabbarController setSelectedIndex:0];

UITabBar *tabBar = self.tabbarController.tabBar;
tabBar.translucent = NO;
[tabBar setBackgroundColor:[UIColor whiteColor]];
UITabBarItem *tabBarItem1 = [tabBar.items objectAtIndex:0];
UITabBarItem *tabBarItem2 = [tabBar.items objectAtIndex:1];

[tabBarItem1 setTitle:@"BROWSE"];
[tabBarItem2 setTitle:@"LIKED"];    

[tabBarItem1 setImage:[[UIImage imageNamed:@"browser-icon"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[tabBarItem1 setSelectedImage:[[UIImage imageNamed:@"browser-sel-icon"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[tabBarItem2 setImage:[[UIImage imageNamed:@"like-icon"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[tabBarItem2 setSelectedImage:[[UIImage imageNamed:@"like-sel-icon"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];

selectedTabIndex = 0;
self.navigationController.navigationBarHidden = TRUE;
[self.navigationController pushViewController:self.tabbarController animated:animation];
}

使用 MFSideMenu,它在此处可用 https://github.com/mikefrederick/MFSideMenu

文档齐全,支持 UITabBarController。

您可以使用 SWRevealViewController - 它紧凑(只有 2 个文件)且易于使用。