Navigator
public protocol Navigator : AnyObject
Represents a type which can navigate to a view controller.
-
Navigate to a view controller.
Declaration
Swift
func navigate(to destinationViewController: UIViewController, modally isModal: Bool, animated: Bool, completion: (() -> Void)?)
Parameters
destinationViewController
The view controller to navigate to.
isModal
Determines whether the navigation is modal or not.
animated
Determines whether the navigation is animated or not.
completion
The closure to execute after the navigation finishes.
-
navigate(to:
Default implementationmodally: animated: completion: ) Default Implementation
Navigate to a view controller.
In the case of a
UIViewController
conforming to theNavigator
protocol, a default implementation of thenavigate(to:,modally:,animated:,completion:)
is provided. In this default implementation, theUIViewController
conforming to theNavigator
protocol calls the appropriate navigation method depending on whether the navigation is modal or not. If the navigation is modal, it presents the destination view controller by calling thepresent(_, animated:, completion:)
. Otherwise, if the navigation is not modal, the navigation controller of the view controller will push the destination view controller by callingpushViewController(_, animated:, completion:)
. If the navigation is not modal and there is no existing navigation controller, this does nothing.Declaration
Swift
public func navigate(to destinationViewController: UIViewController, modally isModal: Bool = false, animated: Bool = true, completion: (() -> Void)? = nil)
Parameters
destinationViewController
The view controller to navigate to.
isModal
Determines whether the navigation is modal or not. This is
false
by default.animated
Determines whether the navigation is animated or not. This is
true
by default.completion
The closure to execute after the navigation finishes. This is
nil
by default.