unable to use UITabBarController with Sliding Side

2019-09-10 07:17发布

问题:

Im trying to combine both UITabBarController and Sliding Side Menu.

For Sliding Side menu, Im using SWRevealViewController

Im successful in creating the sliding menu but Im not be able to include How can I integrate the UITabBarController with SWRevealViewController or is there any other way through which I can incorporate UITabBarController with Sliding Side Menu?

回答1:

Well, you set your tab bar controller as the reveal view controller's front controller, so of course the tab bar controller goes to the right when you reveal your rear controller !!.

Option A:

Managed to integrate it. Below are the steps to do it:

A. Add a new UIViewController to the storyboard.

B. Remove the content view from the newly added UIViewController

C. Make sure "Is Initial View Controller" is checked in IB for the newly added UIViewController.

D. Set the custom class for the newly added UIViewController to SWRevealViewController.

E. Connect it to a view controller that you intend to be the rear view controller - give the segue "sw_rear" identifier in IB. This must be a reveal controller segue type.

F. Connect it to the UITabBarController - give the segue "sw_front" identifier in IB. This must be a reveal controller segue type.

Option B:

MainTabViewController *frontViewController = [[MainTabViewController alloc] init];
RearViewController *rearViewController = [[RearViewController alloc] init];

UINavigationController *frontNavigationController = [[UINavigationController alloc] initWithRootViewController:frontViewController];
UINavigationController *rearNavigationController = [[UINavigationController alloc] initWithRootViewController:rearViewController];

SWRevealViewController *revealController = [[SWRevealViewController alloc] initWithRearViewController:rearNavigationController frontViewController:frontNavigationController];
revealController.delegate = self;

self.viewController = revealController;
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];