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
optional func previewController(_ controller: QLPreviewController, frameFor item: any QLPreviewItem, inSourceView view: AutoreleasingUnsafeMutablePointer<UIView?>) -> CGRectParameters
- controller:
The Qlpreviewcontroller that’s requesting the frame for the preview item.
- item:
The item to preview or dismiss.
- view:
The TP40007428 CH1 SW18 object that contains the preview item as you display it in your app.
By providing a view object to the
viewparameter, you indicate to the Qlpreviewcontroller that you’re specifying the returned Cgrect object’s origin point relative to that view.Provide
nilin this parameter to indicate that you’re specifying the Cgrect origin point in screen coordinates.
Return Value
A 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.
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.
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.