swift - MMDrawerController 不显示导航栏

标签 swift ios9 mmdrawercontroller

我是 swift 和 iOS 开发的新手。 在我的项目中,我使用 MMDrawerController 加载幻灯片菜单,它对于幻灯片工作正常,但是在 AppDelegate 中初始化 MMDrawerController 后,顶部导航栏 [导航 Controller ] 没有显示。注释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

    }

最佳答案

在有关 MMDrawerController 的示例之一中有以下代码:

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

尝试将您的mainPage更改为UINavigationController,并将rootViewController链接到TabBarViewController,您应该可以解决问题。

详细信息:

// 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)

关于swift - MMDrawerController 不显示导航栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37351627/

相关文章:

ios - Swift:将照片添加到自定义相册

background - iOS9 startMonitoringSignificantLocationChanges 终止时不启动应用程序?

ios - react native : how to change status bar icon colors

ios - iOS 中的非典型左侧菜单(附有屏幕)

ios - 如何在 Swift 4 中将数据从 RightViewController 发送到 MainView Controller?

ios - 点击按钮时如何隐藏 collectionView header ?

ios - 将函数传递给变量,以便稍后调用

ios - for循环CGFloat出错

iOS 9 键盘 : This application is modifying the autolayout engine from a background thread, 可能导致引擎损坏和奇怪的崩溃

ios - 具有所有实例的全局状态的自定义 UIControl 元素