<!--
{
  "availability" : [
    "iOS: 4.0.0 -",
    "iPadOS: 4.0.0 -",
    "macCatalyst: 13.1.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "QuickLook",
  "identifier" : "/documentation/QuickLook/QLPreviewControllerDelegate/previewController(_:frameFor:inSourceView:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Quick Look"
    ],
    "preciseIdentifier" : "c:objc(pl)QLPreviewControllerDelegate(im)previewController:frameForPreviewItem:inSourceView:"
  },
  "title" : "previewController(_:frameFor:inSourceView:)"
}
-->

# previewController(_:frameFor:inSourceView:)

Tells the delegate that the system is about to present the preview full screen or dismiss it, and asks for information to provide a zoom effect.

```
optional func previewController(_ controller: QLPreviewController, frameFor item: any QLPreviewItem, inSourceView view: AutoreleasingUnsafeMutablePointer<UIView?>) -> CGRect
```

## Parameters

`controller`

The [`QLPreviewController`](/documentation/QuickLook/QLPreviewController) that’s requesting the frame for the preview item.

`item`

The item to preview or dismiss.

`view`

The [UIView](https://developer.apple.com/library/archive/releasenotes/iPhone/RN-iPhoneSDK/index.html#//apple_ref/doc/uid/TP40007428-CH1-SW18) object that contains the preview item as you display it in your app.

    By providing a view object to the     `view`     parameter, you indicate to the [`QLPreviewController`](/documentation/QuickLook/QLPreviewController)     that you’re specifying the returned     <doc://com.apple.documentation/documentation/CoreFoundation/CGRect>     object’s origin point relative to that view.

    Provide     `nil`     in this parameter to indicate that you’re specifying the     <doc://com.apple.documentation/documentation/CoreFoundation/CGRect>     origin point in screen coordinates.

## Return Value

A <doc://com.apple.documentation/documentation/CoreFoundation/CGRect> object defining the frame rectangle for the preview item as it appears in your app.

## Discussion

Use this delegate method to configure a zoom animation for presenting and dismissing a preview. The zoom proceeds between your own representation of the item and full screen.

> Note:
> Starting with macOS 11, animated transitions are available for Mac apps built with Mac Catalyst. On Mac computers running a version earlier than macOS 11, the system doesn’t call this delegate method.

The system only invokes this method when your app uses the animation option for presentation or dismissal. Specifically, the following statements result in invocation of this method:

```objc
[parentController presentModaViewController: myPreviewController animated: YES];
 // ...
[parentController dismissModalViewControllerAnimated: YES];
```

If you use Boolean <doc://com.apple.documentation/documentation/Swift/false> in these statements, the [`QLPreviewController`](/documentation/QuickLook/QLPreviewController) displays the preview full screen immediately, with no transition effect.

The preview item, and its origin point, can change while displaying a preview. For example, the user may navigate to a different item using the controller, or may rotate the device. Return the correct origin point when zooming to full screen, and when zooming back to your representation of the item.

> Note:
> Zoom animation is most effective on large-screen devices. On iPhone and iPod touch, use a <doc://com.apple.documentation/documentation/UIKit/UINavigationController> object to push the ``doc://com.apple.quicklook/documentation/QuickLook/QLPreviewController`` into view. When using a navigation controller to push a preview, the system doesn’t invoke this method.

To produce a zoom animation, return a <doc://com.apple.documentation/documentation/CoreFoundation/CGRect> object that represents the frame for the preview item as it appears in your app. Use coordinates relative to the <doc://com.apple.documentation/documentation/UIKit/UIView> object that contains the item, and specify that view in the `view` parameter.

Alternatively, you can use screen coordinates for the returned <doc://com.apple.documentation/documentation/CoreFoundation/CGRect> object. In this case, you need to specify <doc://com.apple.documentation/documentation/ObjectiveC/nil-227m0> in the `view` parameter.

To produce a full-screen fade animation rather than a zoom, return a value of <doc://com.apple.documentation/documentation/CoreGraphics/CGRectZero>, or don’t implement 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)