Alexander
Alexander

Reputation: 1494

SWRevealViewController and Tab Bar Controller in detail

This question has been asked before and has been answered, my question is not unique but there must be something missing as none of the structures I have tried works. I am simply trying to achieve the SWRevealViewController "menu" button in each of the scenes of a Tab Bar Controller.

This is the current setup:

enter image description here

Textwise: SWRevealViewController -> reveal view controller set controller (sw_front) -> Navigation Controller -> root view controller (segue) -> Tab Bar controller -> Navigation controller -> Scene

SWRevealViewController *revealViewController = self.revealViewController;
if ( revealViewController )
{
    [self.sidebarButton setTarget: self.revealViewController];
    [self.sidebarButton setAction: @selector( revealToggle: )];
    [self.view addGestureRecognizer:self.revealViewController.panGestureRecognizer];
}

This code is in the viewDidLoad method of each scene, the SWRevealViewController.h is imported and the menu button is declared.

When the menu button is pressed nothing happens.

I have been on this issue for days and I am sure it must be something simple, help really would be appreciated.

Upvotes: 2

Views: 3043

Answers (3)

Mahesh Chaudhari
Mahesh Chaudhari

Reputation: 847

SWRevealViewController with TabBarController in Swift 4

let objSideBarVC = SideBarVC(nibName: "SideBarVC", bundle: nil)
let navSidebar = UINavigationController(rootViewController: objSideBarVC)
 navSidebar.navigationBar.isHidden = true
                    
let objDashboardVC = DashboardVC(nibName: "DashboardVC", bundle: nil)
let navDashboard = UINavigationController(rootViewController: objDashboardVC)
navDashboard.navigationBar.isHidden = true
                    
let mainRevealController = SWRevealViewController.init(rearViewController: navSidebar,frontViewController: navDashboard)

AppDelegate().window?.rootViewController = mainRevealController
mainRevealController.pushFrontViewController(TabBarController, animated: true)

Upvotes: 0

Oshitha Wimalasuriya
Oshitha Wimalasuriya

Reputation: 451

you can use following code Snippet or you can use UITabBarController as root view

UITabBarController *tab = [storyboard instantiateViewControllerWithIdentifier:@"Controller"];        
               [self.revealViewController setFrontViewController:tab];
                [self.revealViewController setFrontViewPosition: FrontViewPositionLeft animated: YES];

Upvotes: 0

MedAmine.Rihane
MedAmine.Rihane

Reputation: 1213

i think you forget sw_rear for side menu segue . those 2 screenshots can help you

sw_front and SWRevealViewControllerSegueSetController for tabbar segue front

sw_rear and SWRevealViewControllerSegueSetController for sidebar viewcontroller segue

rear

and finally this is an example of tabbar with SWRevealViewController that i did look this screenshot .

enter image description here

Upvotes: 2

Related Questions