0

Let say In My Case I have 6 ViewControllers ViewCtrl1, ViewCtrl2, ViewCtrl3 are in SideMenu. And ViewCtrl4, ViewCtl5, ViewCtrl6 are in UITabBar. I am getting issue here that.. when i load any of the UITabBar ViewCtrls they are coming fine. But When Any of the ViewCtrls from Sidemenu i load Up let say i open ViewCtrl2 then that viewctrl2 is load up in UiTabBar's Selected Position and Then in UITabBar Insted of ViewCtrl 4,5,6 Now its load up with ViewCtrl2. ..........

Summerise Line:

After Loading a viewctrl from SideMenu.. That ViewCtrl loads every time In UiTabBar Selection.

See this Image Below:

Desription

Please Help me or comment I tried to Explain But Incase Please help.

Code:

FOR UITabBar:

 func tabBarController(_ tabBarController: UITabBarController, didSelect viewController: UIViewController) {
        print("Selected view controller \(viewController)")
         var storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
        if self.tabBarController?.selectedIndex == 0 {
            // your action, e.g.
            print("bandana")
            let tabViewController1 = storyboard.instantiateViewController(withIdentifier: "HomeViewController")
            self.present(tabViewController1, animated: true, completion: nil)
        }else if self.tabBarController?.selectedIndex == 1{
             print("Tapan")
            let tabViewController2 = storyboard.instantiateViewController(withIdentifier: "SettingsProfileViewController")
            self.present(tabViewController2, animated: true, completion: nil)

        }

    }

For SideMenu: ENSwiftSideMenu

   override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

        print("did select row: \(indexPath.row)")


        switch (indexPath.row) {

        case 0:
            let destViewController = mainStoryboard.instantiateViewController(withIdentifier: "ViewController1")
            sideMenuController()?.setContentViewController(destViewController)
            break

        case 1:
            let destViewController = mainStoryboard.instantiateViewController(withIdentifier: "ViewController2")
            sideMenuController()?.setContentViewController(destViewController)

            break

        case 2:
            let destViewController = mainStoryboard.instantiateViewController(withIdentifier: "ViewController3")
            sideMenuController()?.setContentViewController(destViewController)
            break

             default:
               break

        }
    }

Please Help Guys, Thanks...

rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • Can you please explain what you are trying to achieve? – Karthik Venkatraman Oct 21 '17 at 10:04
  • I just want to open ViewControllers from sidemenu and uiTabBar what ever i hav set . which is not happening – Bandana Choudhury Oct 21 '17 at 10:19
  • 1. Why the heck do you instantiate viewControllers again when you have them already in tabBar? 2. select the viewController from tabBar https://stackoverflow.com/questions/25325923/programmatically-switching-between-tabs-within-swift – Dominik Bucher Oct 21 '17 at 12:46
  • yes i know i don't need to instantiate.But When i am selecting any viewcntrls from sidemenu uiTabBars ViewCtrls are not showing anymore only sidemenu viewCtrls are showing . – Bandana Choudhury Oct 21 '17 at 14:45

0 Answers0