---
title: "present(_:asPopoverRelativeTo:of:preferredEdge:behavior:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsviewcontroller/present(_:aspopoverrelativeto:of:preferrededge:behavior:)"
---

# present(_:asPopoverRelativeTo:of:preferredEdge:behavior:)

Presents another view controller as a popover.

## Declaration

```swift
func present(_ viewController: NSViewController, asPopoverRelativeTo positioningRect: NSRect, of positioningView: NSView, preferredEdge: NSRectEdge, behavior: NSPopover.Behavior)
```

## Parameters

- `viewController`: The other view controller to present as a popover.
- `positioningRect`: The content size of the popover.
- `positioningView`: The view relative to which the popover should be positioned. Must not be nil, or else the view controller raises an doc://com.apple.documentation/documentation/Foundation/NSExceptionName/invalidArgumentException exception.
- `preferredEdge`: The edge of positioningView that the popover should prefer to be anchored to.
- `behavior`: The popover’s closing behavior. See the doc://com.apple.appkit/documentation/AppKit/NSPopover/Behavior-swift.enum enumeration.

## Discussion

Discussion This method calls the present(_:animator:) method on self (the presenting view controller), and passes a popover animator to that method. The presented view controller is the delegate and the content view controller of the popover. You can use NSPopoverDelegate methods to customize the popover. To dismiss the popover, call the dismiss(_:) method on self (the presenting view controller).

## See Also

### Presenting Another View Controller’s Content

- [present(_:animator:)](appkit/nsviewcontroller/present(_:animator:).md)
- [dismiss(_:)](appkit/nsviewcontroller/dismiss(_:)-91my5.md)
- [present(_:asPopoverRelativeTo:of:preferredEdge:behavior:hasFullSizeContent:)](appkit/nsviewcontroller/present(_:aspopoverrelativeto:of:preferrededge:behavior:hasfullsizecontent:).md)
- [presentAsModalWindow(_:)](appkit/nsviewcontroller/presentasmodalwindow(_:).md)
- [presentAsSheet(_:)](appkit/nsviewcontroller/presentassheet(_:).md)
- [present(inWidget:)](appkit/nsviewcontroller/present(inwidget:).md)
