Material: NavigationDrawerController AppDelegate Problem

Created on 17 Mar 2017  路  7Comments  路  Source: CosmicMind/Material

Hello,

First of all, thank you for this awesome library :)

I'm new at iOS World and i really want to use this library. Now, i'm trying to use your Toolbar and NavigationDrawerController. I have a splash screen to control lots of things on my app and when i set a rootview as my main map viewcontroller as AppNavigationDrawerController, SplashScreen won't even start so a lot of problems are appeared for me..

I cannot find how to use your toolbar and navigationdrawercontroller without AppDelegate. As i said i'm new at this. Can you please teach me how i should use it ?

Thank you so much :)

help wanted

Most helpful comment

@WrathChaos, I assume you want to show drawer after your SplashScreen.
You can let your app open SplashScreen first and do your work
Put all code to set rootViewController(currently in applicationDidFinishLaunching) in another function on AppDelegate.

func setDrawerRootView() {
    let appToolbarController = AppToolbarController(rootViewController: RootViewController())
    let leftViewController = LeftViewController()
    let rightViewController = RightViewController()

    window = UIWindow(frame: Screen.bounds)
    window!.rootViewController = AppNavigationDrawerController(rootViewController: appToolbarController, leftViewController: leftViewController, rightViewController: rightViewController)
    window!.makeKeyAndVisible()
}

(Something like above)
And call this method at the time of dismissing the SplashScreen or whenever required.

if let appDelegate = UIApplication.shared.delegate as? AppDelegate {
        appDelegate.setDrawerRootView()
}

You can also set rootViewController from any Controller

if let appDelegate = UIApplication.shared.delegate as? AppDelegate {
        appDelegate.window!.rootViewController = ... //AppNavigationDrawerController
}

Thanks.

All 7 comments

If you're using Controllers, you need to set the rootViewController somewhere. Take a look at http://www.cosmicmind.com/danieldahan/application-architecture-with-material, it may help. You may need to read it two or three times to understand it, I know I did.

Your SplashScreen needs to be part of that hierarchy.

@theolof lol, anything I can make more clear. I'd be happy to rewrite it :)

@WrathChaos thank you :) Can you share some sample code, or a sample project ? Thank you!

@danieldahan Hehe, I'm not sure how to make it easier to understand... Maybe more examples and what they lead to. It was complicated for me because my mindset was "I want to show a snackbar when I click this button", but that's not the way it works :-) and it took a while to understand what happens when adding controllers in a certain order.

@WrathChaos, I assume you want to show drawer after your SplashScreen.
You can let your app open SplashScreen first and do your work
Put all code to set rootViewController(currently in applicationDidFinishLaunching) in another function on AppDelegate.

func setDrawerRootView() {
    let appToolbarController = AppToolbarController(rootViewController: RootViewController())
    let leftViewController = LeftViewController()
    let rightViewController = RightViewController()

    window = UIWindow(frame: Screen.bounds)
    window!.rootViewController = AppNavigationDrawerController(rootViewController: appToolbarController, leftViewController: leftViewController, rightViewController: rightViewController)
    window!.makeKeyAndVisible()
}

(Something like above)
And call this method at the time of dismissing the SplashScreen or whenever required.

if let appDelegate = UIApplication.shared.delegate as? AppDelegate {
        appDelegate.setDrawerRootView()
}

You can also set rootViewController from any Controller

if let appDelegate = UIApplication.shared.delegate as? AppDelegate {
        appDelegate.window!.rootViewController = ... //AppNavigationDrawerController
}

Thanks.

Hi @WrathChaos I haven't heard from you in regards to any sample code, so I will close this issue, please reopen if you need any further help. @talkabhishek Thank you for your response.

@danieldahan is the blog post regarding the application architecture approach still available? I'm getting a 404 from the link. Thank you!

@fredbombadil We are redoing the site and launching it very soon. So it has been taken down, sorry. That said, what setup are you trying to do, I can help you. Thank you! Let's chat on Material Gitter.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tbergeron picture tbergeron  路  5Comments

hu55a1n1 picture hu55a1n1  路  4Comments

chashmeetsingh picture chashmeetsingh  路  5Comments

tskulbru picture tskulbru  路  6Comments

jnystad picture jnystad  路  4Comments