---
title: "present(_:animated:completion:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uiviewcontroller/present(_:animated:completion:)"
---

# present(_:animated:completion:)

Presents a view controller modally.

## Declaration

```swift
func present(_ viewControllerToPresent: UIViewController, animated flag: Bool, completion: (() -> Void)? = nil)
```

## Parameters

- `viewControllerToPresent`: The view controller to display over the current view controller’s content.
- `flag`: Pass doc://com.apple.documentation/documentation/Swift/true to animate the presentation; otherwise, pass doc://com.apple.documentation/documentation/Swift/false.
- `completion`: The block to execute after the presentation finishes. This block has no return value and takes no parameters. You may specify nil for this parameter.

## Mentioned in

Displaying transient content in a popover Getting the user’s attention with alerts and action sheets Presenting selected documents Providing access to directories

## Discussion

Discussion In a horizontally regular environment, the view controller is presented in the style specified by the modalPresentationStyle property. In a horizontally compact environment, the view controller is presented full screen by default. If you associate an adaptive delegate with the presentation controller associated with the object in viewControllerToPresent, you can modify the presentation style dynamically. The object on which you call this method may not always be the one that handles the presentation. Each presentation style has different rules governing its behavior. For example, a full-screen presentation must be made by a view controller that itself covers the entire screen. If the current view controller is unable to fulfill a request, it forwards the request up the view controller hierarchy to its nearest parent, which can then handle or forward the request. Before displaying the view controller, this method resizes the presented view controller’s view based on the presentation style. For most presentation styles, the resulting view is then animated onscreen using the transition style in the modalTransitionStyle property of the presented view controller. For custom presentations, the view is animated onscreen using the presented view controller’s transitioning delegate. For current context presentations, the view may be animated onscreen using the current view controller’s transition style. The completion handler is called after the viewDidAppear(_:) method is called on the presented view controller.

## See Also

### Related Documentation

- [presentedViewController](uikit/uiviewcontroller/presentedviewcontroller.md)
- [presentingViewController](uikit/uiviewcontroller/presentingviewcontroller.md)

### Presenting a view controller

- [show(_:sender:)](uikit/uiviewcontroller/show(_:sender:).md)
- [showDetailViewController(_:sender:)](uikit/uiviewcontroller/showdetailviewcontroller(_:sender:).md)
- [UIViewController.ShowDetailTargetDidChangeMessage](uikit/uiviewcontroller/showdetailtargetdidchangemessage.md)
- [dismiss(animated:completion:)](uikit/uiviewcontroller/dismiss(animated:completion:).md)
- [modalPresentationStyle](uikit/uiviewcontroller/modalpresentationstyle.md)
- [UIModalPresentationStyle](uikit/uimodalpresentationstyle.md)
- [modalTransitionStyle](uikit/uiviewcontroller/modaltransitionstyle.md)
- [UIModalTransitionStyle](uikit/uimodaltransitionstyle.md)
- [isModalInPresentation](uikit/uiviewcontroller/ismodalinpresentation.md)
- [definesPresentationContext](uikit/uiviewcontroller/definespresentationcontext.md)
- [providesPresentationContextTransitionStyle](uikit/uiviewcontroller/providespresentationcontexttransitionstyle.md)
- [disablesAutomaticKeyboardDismissal](uikit/uiviewcontroller/disablesautomatickeyboarddismissal.md)
- [showDetailTargetDidChangeNotification](uikit/uiviewcontroller/showdetailtargetdidchangenotification.md)
