dogo / AKSideMenu

Beautiful iOS side menu library with parallax effect. Written in Swift
MIT License
281 stars 50 forks source link

How to set UITabBar controller as AKSideMenu cotentViewController? #77

Open KuldeepAIP opened 3 years ago

KuldeepAIP commented 3 years ago

Firstly I have used AKSidemenu and when i press any item from sidemenu i move to particular controller like below.

let contentViewController: TestVC = GlobalData.testStoryBoard().instantiateViewController(withIdentifier: "TestVC") as! TestVC
let navController = UINavigationController.init(rootViewController: contentViewController)
self.sideMenuViewController!.setContentViewController(navController, animated: true)
self.sideMenuViewController?.hideMenuViewController()

but now i want to use UITabBarController so after login i use AKSideMenu & UITabBarController like this.

func setSideMenuAsRootViewController() {
    let ContentViewController: TabBarVC = GlobalData.tabBarStoryBoard().instantiateViewController(withIdentifier: "TabBarVC") as! TabBarVC
    let leftMenuViewController: LeftMenuVC = GlobalData.mainStoryBoard().instantiateViewController(withIdentifier: "LeftMenuVC") as! LeftMenuVC

    let sideMenuViewController: AKSideMenu = AKSideMenu(contentViewController: ContentViewController, leftMenuViewController: leftMenuViewController, rightMenuViewController: nil)

    self.window?.rootViewController = sideMenuViewController
}

but now when i press any sidemenu item it moves to only UITabBar initial controller. here is my code.

let contentViewController: TabBarVC = GlobalData.tabBarStoryBoard().instantiateViewController(withIdentifier: "TabBarVC") as! TabBarVC
self.sideMenuViewController!.setContentViewController(contentViewController, animated: true)
self.sideMenuViewController?.hideMenuViewController()

1 solution to move UITabBar particular subcontroller is to use UITabBarController selectedIndex.

If there's any proper solution to do that then please suggest me.