使用UITabBar和Sidemenu时,ViewControllers无法正确加载

时间:2017-10-21 09:47:56

标签: ios swift uitabbar

让我说在我的案例中我有6个ViewControllers ViewCtrl1,ViewCtrl2,ViewCtrl3都在SideMenu中。而ViewCtrl4,ViewCtl5,ViewCtrl6都在UITabBar中。 我在这里遇到问题..当我加载任何UITabBar ViewCtrls时,它们都会好起来的。 但是当我加载Sidemenu的任何ViewCtrls时,我想打开ViewCtrl2,然后在UiTabBar的选定位置加载viewctrl2,然后在UITabBar中加载ViewCtrl 4,5,6,现在用ViewCtrl2加载它。 ..........

Summerise Line:

从SideMenu加载viewctrl后..每次在UiTabBar选择中加载ViewCtrl。

请参阅下图:

Desription

请帮助我或评论我试着解释但是请帮忙。

代码:

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)

        }

    }

对于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

        }
    }

请帮助伙计们,谢谢...

0 个答案:

没有答案