我在我的项目中使用 MMDrawerController。我按照这个http://swiftdeveloperblog.com/left-side-menu-navigation-drawer-example-with-swift/ 在我的应用程序中设置 MMDrawerController。我在AppDelegate.swift文件的教程中使用了相同的代码。
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var homeController : MMDrawerController?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
//NSNotificationCenter.defaultCenter().addObserver(self, selector: "detectRotation", name: UIDeviceOrientationDidChangeNotification, object: nil)
_ = self.window!.rootViewController
let mainStoryBoard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let homeViewController = mainStoryBoard.instantiateViewControllerWithIdentifier("HomeViewController") as! HomeViewController
let menuViewController = mainStoryBoard.instantiateViewControllerWithIdentifier("MenuViewController") as! MenuViewController
let leftSideNavigation = UINavigationController(rootViewController: menuViewController);
let homeNavigation = UINavigationController(rootViewController: homeViewController);
homeController = MMDrawerController(centerViewController: homeNavigation, leftDrawerViewController: leftSideNavigation);
homeController!.openDrawerGestureModeMask = MMOpenDrawerGestureMode.PanningCenterView
homeController!.closeDrawerGestureModeMask = MMCloseDrawerGestureMode.PanningCenterView
homeController?.setMaximumLeftDrawerWidth(UIScreen.mainScreen().bounds.width, animated: true, completion: nil)
window!.rootViewController = homeController // current Entry point
window!.makeKeyAndVisible();
return true
}
}
在我运行应用程序时设置代码后,应用程序的入口点已更改为homeController(主屏幕应仅出现用户登录或创建新帐户)
我从我的 AppDelegate 文件中删除了这些行
window!.rootViewController = homeController // current Entry point
window!.makeKeyAndVisible();
所以应用程序从我设置的入口点开始,即:登录页面。但是现在发生的是抽屉在按下菜单按钮(汉堡包)时没有显示。那么我需要更改/添加什么以实现我的入口点并使我的抽屉工作?