<!--
{
  "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/UIViewControllerPreviewingDelegate/previewingContext(_:viewControllerForLocation:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(pl)UIViewControllerPreviewingDelegate(im)previewingContext:viewControllerForLocation:"
  },
  "title" : "previewingContext(_:viewControllerForLocation:)"
}
-->

# previewingContext(_:viewControllerForLocation:)

Called when the user has pressed a source view in a previewing view controller, thereby obtaining a surrounding blur to indicate that a preview (peek) is available.

```
func previewingContext(_ previewingContext: any UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController?
```

## Parameters

`previewingContext`

The context object for the previewing view controller.

`location`

The location of the touch in the source view’s coordinate system.

## Return Value

The view controller whose view you want to provide as the preview (peek), or `nil` to disable preview..

## Discussion

Implement this method to return the preview view controller.

To indicate that a particular portion of the source view is responding to the user’s force touch, set the context object’s [`sourceRect`](/documentation/UIKit/UIViewControllerPreviewing/sourceRect) property to the desired rectangle. For example, if the context object’s [`sourceView`](/documentation/UIKit/UIViewControllerPreviewing/sourceView) property is a table view, you can set the [`sourceRect`](/documentation/UIKit/UIViewControllerPreviewing/sourceRect) property to the frame of the row indicated by the `location` parameter’s value. When the system presents the preview (peek), it appears to originate from the selected row.

You can disable preview by returning `nil` from this method.

---

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)