How to implement a SideNavigationViewController into a UIViewController?

混江龙づ霸主 提交于 2019-12-06 10:44:34

问题


A little confused on how to implement this into my main view controller. The example project shows it as a navigation controller, but I wasn't able to add an existing class on a fresh navigation controller or my current UIViewController. I could just be implementing it wrong though. Much appreciation if I can gain some traction on how to work with these.


回答1:


If you could share some code that would be great.

How things work:

Navigation Controllers

There are currently 4 different Navigation Controllers that each offer their own features. The controllers can be used individually, or together.

SideNavigationViewController

The SideNavigationViewController offers 3 bodies to display content: mainViewController, leftViewController, and rightViewController.

MainViewController

The mainViewController must always exist, and has a facility for transitioning between view controllers using the transitionFromMainViewController method. Using this method is as easy as passing a UIViewController in its first parameter.

sideNavigationViewController?.transitionFromMainViewController(InboxViewController())

There are further parameters that allow for animations, completions, etc... to be set when transitioning between view controllers.

LeftViewController and RightViewController

The leftViewController and rightViewController can be set only once. To make them dynamic, you would need to use another Navigation Controller as its view controller.

NavigationBarViewController

The NavigationBarViewController offers a NavigationBarView along side the ability to manage two UIViewControllers, the mainViewController and the floatingViewController.

MainViewController

The mainViewController is like the SideNavigationViewController's mainViewController, and has a transitionFromMainViewController method that transitions from view controller to view controller in the body portion of the NavigationBarViewController.

FloatingViewController

The floatingViewController is a modalViewController and when set, it pops over MainViewController and NavigationBarView. Setting that value is like so:

navigationBarViewController?.floatingViewController = InboxViewController()

To close and hide the floatingViewController set it to nil, like so.

navigationBarViewController?.floatingViewController = nil

SearchBarViewController

The SearchBarViewController offers a single transitioning mainViewController, as well, has a SearchBarView at the top. Transitioning the mainViewController is like so:

sideNavigationBarViewController?.transitionFromMainViewController(InboxViewController())

MenuViewController

The MenuViewController is another controller that has a mainViewController, which takes the entire screen. Floating above it, is a MenuView that is used to transition between mainViewControllers.

menuViewController?.transitionFromMainViewController(InboxViewController())

Final Notes

These Navigation Controllers can be used in any combination and any amount of times creating a robust and intricate stack of controllers that act like one.

I hope this helps :)



来源:https://stackoverflow.com/questions/35647528/how-to-implement-a-sidenavigationviewcontroller-into-a-uiviewcontroller

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