2

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.

Kyle C. Beachem
  • 51
  • 1
  • 10

1 Answers1

3

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

CosmicMind
  • 1,499
  • 1
  • 10
  • 6
  • Are there best practices to do a SideMenu? For the moment in didSelectRowAtIndexPath I have sideNavigationViewController?.transitionFromMainViewController(testVC, duration: 0.5, options: [], animations: nil, completion: nil) And in testVC I have sideNavigationViewController?.closeLeftView() What are the best practices to deal with my SideMenu, for Example I can use an array of ViewControllers, and use the indexPath? – papay0 Feb 26 '16 at 17:02
  • When do you think you could provide a working example? – papay0 Feb 26 '16 at 17:10
  • Generally our approach is to handle many ways developers will want to approach a problem. Your solution would work, and could be very effective, though it seems like now logic is being sprinkled around rather than localized. What could improve your solution, is remove the testVC.closeLeftView() call, and place the closeLeftView call in the completion block of the transitionFromMainViewController. – CosmicMind Feb 26 '16 at 17:15
  • I am providing an example today with the latest updates and releases. I was slightly held up yesterday, as many people are looking for answers when dealing with Navigation Controllers. @user3369462 – CosmicMind Feb 26 '16 at 17:16