Search code examples
swift3cosmicmind

Cosmicmind/Material: difference between NavigationController and ToolbarController


I'm working on a app that is written with swift3 in Xcode8. My app implements the Cosmicmind-material-framework.

While the working i tried to understand what the difference between NavigationController and ToolbarController is. (maybe someone can additionaly explain the difference to PageTabBarController, too)

I don't really get it because it seems that the navigationController contains a toolbarController. So why should i use both if i can only use the navigationController and prepare all "toolbar-items" there.

Shortly to the app:

  • NavigationDrawerController
    • NavigationController
      1. Site 1
      2. Site 2
      3. PageTabBarController
        1. Site Red
        2. Site Blue
        3. Site Yellow

Solution

  • good question.

    The main difference between a NavigationController and ToolbarController is that a NavigationController is a subclass of UINavigationController and gives you all the benefits of that class while allowing you to customize the look and feel as if you would a ToolbarController.

    The ToolbarController provides a different type of flow, one that transitions the rootViewController using the transition method between view controllers. It also provides a floating view controller that can effectively be used in many ways.

    Like the ToolbarController, the PageTabBarController inherits from the RootController, which provides the same rootViewController transitioning, but by default offers a UIPageViewController as the initial rootViewController.

    So what is the point of all these different controllers? The main design reason is to allow you to stack view controllers that have these special controls in order to create more complex navigational architectures without the fuss of maintaining their organization. Each is accessible within the hierarchy while managing their own code complexities. The user has the perception that they are all working together seamlessly.

    A good example of this is the CardTableView sample project, which also shows how to layout Cards within the PageTabBarController using TableViews that have dynamic heights based on content. For the most part, the entire UI is driven using persisted data powered by Graph.

    Hope that helps :)