我正在使用MMDraweController。它工作得很好。我有rootViewController的问题。当应用程序启动时,它加载loginViewController。所以我不想要那里的侧栏菜单(loginViewController没有任何导航控制器)。我的问题是使用appView下面的代码从viewController开始,而不是loginViewController。如何使用没有侧栏菜单的登录页面和带侧栏的viewController?
var rootViewController = self.window!.rootViewController
let mainStoryBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
var centerViewController = mainStoryBoard.instantiateViewControllerWithIdentifier("ViewController") as ViewController
//var rootViewController = centerViewController
var leftViewController = mainStoryBoard.instantiateViewControllerWithIdentifier("SideBarMenuViewController") as SideBarMenuViewController
var leftSideNav = UINavigationController(rootViewController: leftViewController)
var centerSideNav = UINavigationController(rootViewController: centerViewController)
centerContainer = MMDrawerController(centerViewController: centerSideNav, leftDrawerViewController: leftSideNav)
centerContainer!.openDrawerGestureModeMask = MMOpenDrawerGestureMode.PanningCenterView
centerContainer!.closeDrawerGestureModeMask = MMCloseDrawerGestureMode.PanningCenterView
window!.rootViewController = centerContainer
window!.makeKeyAndVisible()
答案 0 :(得分:1)
当您加载loginPageViewController时,只需输入以下代码:
var appDelegate: AppDelegate = UIApplication.sharedApplication().delegate as AppDelegate
appDelegate.centerContainer!.openDrawerGestureModeMask = MMOpenDrawerGestureMode.None
答案 1 :(得分:0)
太晚但可能会帮助其他人......
我通过在AppDelegate.swift
中创建一个函数解决了这个问题func goToMainVC() {
var rootViewController = self.window!.rootViewController
let mainStoryBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
var centerViewController = mainStoryBoard.instantiateViewControllerWithIdentifier("ViewController") as ViewController
//var rootViewController = centerViewController
var leftViewController = mainStoryBoard.instantiateViewControllerWithIdentifier("SideBarMenuViewController") as SideBarMenuViewController
var leftSideNav = UINavigationController(rootViewController: leftViewController)
var centerSideNav = UINavigationController(rootViewController: centerViewController)
centerContainer = MMDrawerController(centerViewController: centerSideNav, leftDrawerViewController: leftSideNav)
centerContainer!.openDrawerGestureModeMask = MMOpenDrawerGestureMode.PanningCenterView
centerContainer!.closeDrawerGestureModeMask = MMCloseDrawerGestureMode.PanningCenterView
window!.rootViewController = centerContainer
window!.makeKeyAndVisible()
}
然后在登录或其他ViewController结束后调用此函数
let appDelegate = UIApplication.shared.delegate as! AppDelegate
appDelegate.goToMainVC()
那就是它!