Cosmicmind/Material: difference between NavigationController and ToolbarController

拥有回忆 提交于 2020-01-06 17:57:25

问题


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

回答1:


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 :)



来源:https://stackoverflow.com/questions/40528928/cosmicmind-material-difference-between-navigationcontroller-and-toolbarcontroll

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!