<!--
{
  "availability" : [
    "iOS: 9.0.0 - 13.0.0",
    "iPadOS: 9.0.0 - 13.0.0",
    "macCatalyst: 13.1.0 - 13.1.0",
    "tvOS: 9.0.0 - 13.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIViewController/registerForPreviewing(with:sourceView:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIViewController(im)registerForPreviewingWithDelegate:sourceView:"
  },
  "title" : "registerForPreviewing(with:sourceView:)"
}
-->

# registerForPreviewing(with:sourceView:)

Registers a view controller to participate with 3D Touch preview (peek) and commit (pop).

```
func registerForPreviewing(with delegate: any UIViewControllerPreviewingDelegate, sourceView: UIView) -> any UIViewControllerPreviewing
```

## Parameters

`delegate`

The delegate object mediates the presentation of views from the preview (peek) view controller and the commit (pop) view controller. In practice, these two are typically the same view controller. The delegate performs this mediation through your implementation of the methods of the [`UIViewControllerPreviewingDelegate`](/documentation/UIKit/UIViewControllerPreviewingDelegate) protocol.

`sourceView`

The view, in the view hierarchy of the receiver of this method call, that invokes a preview when pressed by the user.

    When lightly pressed, the source view remains visually sharp while surrounding content blurs. When pressed more deeply, the system calls the [`previewingContext(_:viewControllerForLocation:)`](/documentation/UIKit/UIViewControllerPreviewingDelegate/previewingContext(_:viewControllerForLocation:))     method in your     `delegate`     object, which presents the preview (peek) view from another view controller.

## Return Value

A context object for managing the preview. This object conforms to the [`UIViewControllerPreviewing`](/documentation/UIKit/UIViewControllerPreviewing) protocol.

## Discussion

A preview, or *peek* in end-user terminology, provides additional content related to the view the user pressed (that is, related to the `sourceView` view).

Calling this method does three things:

- Registers the previewing view controller (the one that receives this method call) to participate with 3D Touch preview and commit
- Designates the source view, from the receiver’s view hierarchy, as the view to respond to a forceful touch
- Designates a delegate object for mediating the presentation of the preview (peek) and commit (pop) views as a user requests them in turn by pressing more deeply

You can designate more than one source view for a single registered view controller, but you cannot designate a single view as a source view more than once.

The lifetime of this method’s returned context object is managed by the system. If you need to explicitly unregister a view controller, pass its context object to the [`unregisterForPreviewing(withContext:)`](/documentation/UIKit/UIViewController/unregisterForPreviewing(withContext:)) method. If you do not unregister a view controller, the system automatically unregisters it when the view controller is deallocated.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)