I am using CosmicMaterial (http://www.cosmicmind.io/material) for implementing Sidemenu or a.k.a drawer menu. I've read the documentation and how to run the sample projects of this cool library. I was able to see the demo of Sidemenu of CosmicMaterial.
One problem though is that I am having a hard time figuring out how to embed a navigation controller in Sidemenu.
My code in Appdelegate didFinishLaunchingWithOptions
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Get view controllers from storyboard
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let homeTableViewController = storyboard.instantiateViewControllerWithIdentifier("HomeTableViewController") as! HomeTableViewController
let sideViewController = storyboard.instantiateViewControllerWithIdentifier("SideTableViewController") as! SideTableViewController
// var navigationController = storyboard.instantiateViewControllerWithIdentifier("RootNavigationController") as! NavigationController
//
// var sideNavigationController = storyboard.instantiateViewControllerWithIdentifier("SideNavigationController") as! NavigationController
//
// navigationController = NavigationController(rootViewController: homeTableViewController)
// sideNavigationController = NavigationController(rootViewController: sideViewController)
//
//
// Configure the window with the SideNavigationController as the root view controller
window = UIWindow(frame: UIScreen.mainScreen().bounds)
window?.rootViewController = SideNavigationController(rootViewController: homeTableViewController, leftViewController: sideViewController)
window?.makeKeyAndVisible()
return true
}
And here's my layout in storyboard. All ids of each xibs have been set.
I had the same problem before. I just figured out that I am assigning the navigonController improperly. See the codes below:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Get view controllers from storyboard
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let rootViewController = storyboard.instantiateViewControllerWithIdentifier("RootViewController") as! RootViewController
let sideViewController = storyboard.instantiateViewControllerWithIdentifier("SideViewController") as! SideViewController
let navCon2 = NavigationController(rootViewController: sideViewController)
let navCon = NavigationController(rootViewController: rootViewController)
let sideNavigationController = SideNavigationController(rootViewController: navCon, leftViewController: navCon2)
sideNavigationController.enabledLeftTapGesture = true
sideNavigationController.enabledLeftPanGesture = true
sideNavigationController.enableHideStatusbar = false
// Configure the window with the SideNavigationController as the root view controller
window = UIWindow(frame: UIScreen.mainScreen().bounds)
window?.rootViewController = sideNavigationController
window?.makeKeyAndVisible()
return true
}
Note that you have to set the properties correctly of the SideNavigationController. And unhide the statusbar, or else you'll experience annoying bug when showing the side menu.
Cheers!