---
title: "previewController(_:frameFor:inSourceView:)"
framework: quicklook
role: symbol
role_heading: Instance Method
path: "quicklook/qlpreviewcontrollerdelegate/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.

## Declaration

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

## Parameters

- `controller`: The doc://com.apple.quicklook/documentation/QuickLook/QLPreviewController that’s requesting the frame for the preview item.
- `item`: The item to preview or dismiss.
- `view`: The 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 doc://com.apple.quicklook/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

Return Value A CGRect object defining the frame rectangle for the preview item as it appears in your app.

## Discussion

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: [parentController presentModaViewController: myPreviewController animated: YES];  // ... [parentController dismissModalViewControllerAnimated: YES]; If you use Boolean false in these statements, the 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 UINavigationController object to push the 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 CGRect object that represents the frame for the preview item as it appears in your app. Use coordinates relative to the UIView object that contains the item, and specify that view in the view parameter. Alternatively, you can use screen coordinates for the returned CGRect object. In this case, you need to specify nil in the view parameter. To produce a full-screen fade animation rather than a zoom, return a value of CGRectZero, or don’t implement this method.

## See Also

### Responding to preview requests

- [previewController(_:transitionImageFor:contentRect:)](quicklook/qlpreviewcontrollerdelegate/previewcontroller(_:transitionimagefor:contentrect:).md)
- [previewController(_:transitionViewFor:)](quicklook/qlpreviewcontrollerdelegate/previewcontroller(_:transitionviewfor:).md)
- [previewControllerWillDismiss(_:)](quicklook/qlpreviewcontrollerdelegate/previewcontrollerwilldismiss(_:).md)
- [previewControllerDidDismiss(_:)](quicklook/qlpreviewcontrollerdelegate/previewcontrollerdiddismiss(_:).md)
