gpt4 book ai didi

swift - MMDrawerController 不显示导航栏

转载 作者:可可西里 更新时间:2023-11-01 01:35:54 26 4
gpt4 key购买 nike

我是 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....

尝试使用 UINavigationController 更改您的 mainPage,并将 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com