UIViewController

extension UIViewController
  • Embeds a child UIViewController.

    Declaration

    Swift

    public func embed(child newChild: UIViewController, in container: UIView? = nil)

    Parameters

    newChild

    The child UIViewController to embed.

    container

    The container UIView to embed the child view controller’s view to.

  • Unembed as a child UIViewController of a parent UIViewController if it exists.

    Declaration

    Swift

    public func unembed()
  • Unembeds all children UIViewController.

    Declaration

    Swift

    public func unembedAllChildren()
  • Presents UIViewController into the navigationController view stack or on the UIViewController.topMost()

    Declaration

    Swift

    public func showModally(in viewController: UIViewController? = nil, completion: (() -> Void)? = nil)

    Parameters

    viewController

    The UIViewController where it will be presented into

    completion

    The closure to be executed once the presentation is finished

  • Returns the top most view controller.

    Declaration

    Swift

    public static func topMost(atRoot root: UIViewController? = UIApplication.shared.keyWindow?.rootViewController) -> UIViewController?

    Parameters

    root

    The root UIViewController to start traversing toward the top most view controller.

    Return Value

    The top most UIViewController.

  • Either dismisses or pops the view controller with a completion handler.

    This method checks if the view controller is in a navigation stack and if it does, it pops the view controller from the stack. If the view controller is not in a navigation stack, this method tries to dismiss the view controller.

    Declaration

    Swift

    public func close(animated: Bool,
                      completion: (() -> Void)? = nil)

    Parameters

    animated

    Specify true to animate the transition or false if you do not want the transition to be animated.

    completion

    The closure to execute after the transition finishes. This closure has no return value and takes no parameters. You may specify nil for this parameter.