导航栏没有显示MMDrawerController

时间:2016-05-20 16:33:55

标签: swift ios9 mmdrawercontroller

我是swift和iOS开发的新手。 在我的项目中,我正在使用MMDrawerController加载slidein菜单,它适用于幻灯片,但在AppDelegate中初始化MMDrawerController后,顶部导航栏[导航控制器]未显示。注释MMDrawer初始化显示导航栏和单击事件正在激活,以下是导航初始化代码,

func buildNavigationDrawer()
    {

            // Instantiate Main.storyboard
            let mainStoryBoard:UIStoryboard = UIStoryboard(name:"Main", bundle:nil)

            // Create View Controllers
            let mainPage:TabBarViewController = mainStoryBoard.instantiateViewControllerWithIdentifier("TabBarViewController") as! TabBarViewController

            let leftSideMenu:LeftSideViewController = mainStoryBoard.instantiateViewControllerWithIdentifier("LeftSideViewController") as! LeftSideViewController

            let rightSideMenu:RightSideViewController = mainStoryBoard.instantiateViewControllerWithIdentifier("RightSideViewController") as! RightSideViewController



            // Wrap into Navigation controllers
            let leftSideMenuNav = UINavigationController(rootViewController:leftSideMenu)
            let rightSideMenuNav = UINavigationController(rootViewController:rightSideMenu)

            // Cerate MMDrawerController
            drawerContainer = MMDrawerController(centerViewController: mainPage, leftDrawerViewController: leftSideMenuNav, rightDrawerViewController: rightSideMenuNav)

            drawerContainer!.openDrawerGestureModeMask = MMOpenDrawerGestureMode.PanningCenterView
            drawerContainer!.closeDrawerGestureModeMask = MMCloseDrawerGestureMode.PanningCenterView

            // Assign MMDrawerController to our window's root ViewController
            window?.rootViewController = drawerContainer

    }

1 个答案:

答案 0 :(得分:2)

在其中一个关于MMDrawerController的示例中,有以下代码:

 self.drawerController = [[MMDrawerController alloc]
                     initWithCenterViewController:navigationController....

尝试使用与mainPage关联的rootViewController更改UINavigationController TabBarViewController,您应该解决问题。

<强> DETAIL

// Wrap into Navigation controllers
            let leftSideMenuNav = UINavigationController(rootViewController:leftSideMenu)
            let rightSideMenuNav = UINavigationController(rootViewController:rightSideMenu)
            let centerMenuNav = UINavigationController(rootViewController: mainPage)

            // Cerate MMDrawerController
            drawerContainer = MMDrawerController(centerViewController: centerMenuNav, leftDrawerViewController: leftSideMenuNav, rightDrawerViewController: rightSideMenuNav)