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.

Available where Self: UIViewController

  • Default Implementation

    Navigate to a view controller.

    In the case of a UIViewController conforming to the Navigator protocol, a default implementation of the navigate(to:,modally:,animated:,completion:) is provided. In this default implementation, the UIViewController conforming to the Navigator 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 the present(_, animated:, completion:). Otherwise, if the navigation is not modal, the navigation controller of the view controller will push the destination view controller by calling pushViewController(_, 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.