0

我想将 SideNavigationController (SlideOutBar) 与 BottomNavigationController (BottomNavigationController) 一起使用

我的用例类似于示例“食谱”中的“应用程序”。当点击“食谱”时,底部有一个带有标签的表格。我的用例我想在侧边栏中使用“Recipes A”、“Recipes B”、“Recipes C”等...在其中使用不同的选项卡组合或没有选项卡栏的视图更新主视图。

我有点困惑如何从 SideBarNavigation 中切换出这些组合。在我的应用程序委托中,我有:

   let storyboard = UIStoryboard(name: "Main", bundle: nil)
    let mainViewController = storyboard.instantiateViewControllerWithIdentifier("mainViewController") as! MainViewController
    let sideViewController = storyboard.instantiateViewControllerWithIdentifier("sideViewController") as! SideViewController
    let scratchPadViewController = storyboard.instantiateViewControllerWithIdentifier("scratchPadViewController") as! ScratchPadViewController


    bottomNavigationController.viewControllers = [mainViewController, scratchPadViewController]
    bottomNavigationController.selectedIndex = 0
    bottomNavigationController.tabBar.tintColor = MaterialColor.teal.base
    bottomNavigationController.tabBar.backgroundColor = MaterialColor.grey.darken4


    // Configure the window with the SideNavigationController as the root view controller
    window = UIWindow(frame: UIScreen.mainScreen().bounds)
    window?.rootViewController = SideNavigationController(rootViewController: bottomNavigationController, leftViewController: sideViewController)
    window?.makeKeyAndVisible()

在我的 SideBar 案例 0 中,一个新的选项卡组合,案例 1 只有一个控制器,没有选项卡,案例 3 原始选项卡集等...如何通过单击侧边栏上的项目进行转换?我是否创建一个新的 bottomNavigationController 然后设置它?我要更新现有的吗?

           switch indexPath.row {
        case 0:
            //NEW COMBINATION OF TABS
            let storyboard = UIStoryboard(name: "Main", bundle: nil)
            let mainViewController = storyboard.instantiateViewControllerWithIdentifier("mainViewController") as! MainViewController
            let blueViewController = storyboard.instantiateViewControllerWithIdentifier("blueViewController") as! BlueViewController

            getAppDelegate().bottomNavigationController.setViewControllers([mainViewController, blueViewController], animated: true)
            //remove scan button
            mainViewController.hasScanButton = false
            mainViewController.hasTabbar = true

            //sideNavigationController?.closeLeftView()
            //sideNavigationController?.transitionFromRootViewController(getAppDelegate().bottomNavigationController)
            //sideNavigationController?.transitionFromRootViewController(getAppDelegate().bottomNavigationController,
                                                                       duration: 1,
                                                                       options: .TransitionNone,
                                                                       animations: nil,
                                                                       completion: { [weak self] _ in
                                                                        self?.sideNavigationController?.closeLeftView()
                })
        case 1:
            //place terminal
            let mainViewController = storyboard!.instantiateViewControllerWithIdentifier("mainViewController") as! MainViewController

            //remove scan button
            mainViewController.hasScanButton = false
            mainViewController.hasTabbar = false



            sideNavigationController?.transitionFromRootViewController(mainViewController,
                                                                       duration: 1,
                                                                       options: .TransitionNone,
                                                                       animations: nil,
                                                                       completion: { [weak self] _ in
                                                                        self?.sideNavigationController?.closeLeftView()})
        default:
            break
        }

谢谢

4

0 回答 0