1

I have this in appDelegate:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

            window = UIWindow(frame: UIScreen.mainScreen().bounds)
            let nav = NavigationViewController(rootViewController: MenuViewController(rootViewController: FeedVC()))
            window?.rootViewController = SideNavigationController(rootViewController: nav, leftViewController: LeftVC(), rightViewController: nil)
            window?.makeKeyAndVisible()
}

This works fine. My FeedVC is displayed and I can access the LeftVC with SideNavigationController. (Btw, is it a good way of doing it ?)

Then in my FeedVC class, I want to add titleLabel (navigationItem) to the navigationBar but navigationController is nil !

So I think my FeedVC is not embed in NavigationController. But I'm not using storyboard for this. How can I do this programmatically and take in count that there is also a SideNavigationController at the very top...

Thanks for helping!

Ugo
  • 13
  • 3

1 Answers1

0

Yes, all looks good, except, you do not need to set the rightViewController to nil. You can leave it out completely.

The issue with the titleLabel is that your FeedVC is a child of the MenuViewController. The MenuViewController is a child of the Nav, so the navigationItem should be set in the MenuViewController for this reason. You could flip the MenuViewController and NavigationController relationship, so that the Nav is a child of the Menu. Then you would be able to set the FeedVC navigationItem accordingly.

Hope that helps :)

Also, the framework is Material, not Material Kit. Might be better for search to correct that :)

CosmicMind
  • 1,499
  • 1
  • 10
  • 6