Skip to content

Navigation Helpers (dismiss, replace, unwind)

Luke Zhao edited this page Feb 12, 2017 · 1 revision

Hero provides some useful navigation extension methods on UIViewController. Use these alongside with pushViewController, presentViewController to navigate between view controllers.

func hero_dismissViewController()

 Dismiss the current view controller with animation. Will perform a navigationController.popViewController 
 if the current view controller is contained inside a navigationController.

func hero_replaceViewController(with:UIViewController)

 Replace the current view controller with another VC on the navigation/modal stack.

func hero_unwindToRootViewController()

 Unwind to the root view controller using Hero.

func hero_unwindToViewController(_ toViewController:)

 Unwind to a specific view controller using Hero.

func hero_unwindToViewController(withSelector: Selector)

 Unwind to a view controller that responds to the given selector using Hero.

func hero_unwindToViewController(withClass: AnyClass)

 Unwind to a view controller with given class using Hero.

func hero_unwindToViewController(withMatchBlock: (UIViewController) -> Bool)

 Unwind to a view controller that the match block returns true on.