Search code examples
swiftmmdrawercontroller

Can it be non rootviewcontroller?


I'm implementing a drawer layout design in an app. But my app starts with a small screen with an animated logo (simple HTML5 animation), then a login screen (g+ and Facebook), then the main screen where I'm implementing the MMDrawerController.

The question is in my AppDelegate:

 window?.rootViewController = centerContainer
 window?.makeKeyAndVisible()

So the app start in this screen. Is it possible to not make rootviewcontroller the center container and still using MMDrawerController?

I need to add MMDrawerController to my third viewcontroller in my app But, in order to MMDrawerController to work, it requires to be the rootViewController

I allready tried to add to my first ViewController an Empty MMDrawerLayout but, then, the third controller no longer works

 //global var 
 var centerContainer : MMDrawerController?
 // then the appdelegate 
 let rootViewController = self.window!.rootViewController
 let mainStoryBoard:UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
 let centerViewController = mainStoryBoard.instantiateViewControllerWithIdentifier("GaleriaPeliculas")

 let leftViewController = mainStoryBoard.instantiateViewControllerWithIdentifier("LeftSideViewController")

 let leftSideNav = UINavigationController(rootViewController: leftViewController)
 let centerSideNav = UINavigationController(rootViewController: centerViewController)

 //And here is the problem, 
 window?.rootViewController = centerContainer //how can it work without this line??
 window?.makeKeyAndVisible()

Solution

  • Is it possible to not make rootviewcontroller the center container and still using MMDrawerController?

    No. You need to keep MMDrawerController as the rootViewController if you still want to make use of the left/right drawers. It's no different than a UITabBarController in the sense that it contains multiple view controllers to be conditionally displayed.