Protocol: QLPreviewControllerDelegate

Overview

Implement the methods of this protocol in the delegate of a QLPreviewController (Quick Look preview controller) object to:Called when a Quick Look preview is about to be presented full screen or dismissed, to provide a zoom effect.Called by the Quick Look preview controller before trying to open a URL.Called when the Quick Look preview controller is about to be presented full screen or dismissed; used to provide a smooth transition when zooming. (required)Called after the preview controller is closed.Called before the preview controller is closed.

Instance Method Summary (collapse)

Instance Method Details

- (CGRect) previewController(controller, frameForPreviewItem:item, inSourceView:view)

Called when a Quick Look preview is about to be presented full screen or dismissed, to provide a zoom effect. Use this delegate method to configure a zoom animation for presenting and dismissing a Quick Look preview. The zoom proceeds between your own representation of the item and full screen.This method is invoked only when your application uses the animation option for presentation or dismissal. Specifically, the following statements result in invocation of this method:If you instead use Boolean NO in these statements, the Quick Look preview controller displays the preview full-screen immediately, with no transition effect.The preview item, and its origin point, can change while a preview is displayed. For example, the user may navigate to a different item using the controller, or may rotate the device. Always 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, Apple encourages you to instead use a UINavigationController object to push the Quick Look preview controller into view. When using a navigation controller to push a preview, this method is not invoked.

To produce a zoom animation, return a CGRect object that represents the frame for the preview item as it appears in your application. 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 must specify nil in the view parameter.To produce a full-screen fade animation rather than a zoom, return a value of CGRectZero, or leave this method unimplemented.

Parameters:

  • controller (QLPreviewController)

    The Quick Look preview controller that is requesting the frame for the preview item.

  • item (Object)

    The item to be previewed or dismissed.

  • view (Pointer)

    The UIView object that contains the preview item as you display it in your application.By providing a view object to the view parameter, you indicate to the Quick Look preview controller that you are specifying the returned CGRect object’s origin point relative to that view.Provide nil in this parameter to indicate that you are specifying the CGRect origin point in screen coordinates.

Returns:

  • (CGRect)

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

- (Boolean) previewController(controller, shouldOpenURL:url, forPreviewItem:item)

Called by the Quick Look preview controller before trying to open a URL. This method comes into play when the user taps a URL link in a preview. If you return YES, the Quick Look preview controller invokes the openURL: method on the UIApplication object, sending it the value of the url parameter. If you return NO, the openURL: method is not invoked.If you do not implement this method, it defaults to returning YES.

Parameters:

  • controller (QLPreviewController)

    The Quick Look preview controller that is asking the delegate to handle a user tap on a URL.

  • url (NSURL)

    The URL, from the displayed preview, that the user tapped.

  • item (Object)

    The item being displayed in the preview.

Returns:

  • (Boolean)

    A Boolean value indicating whether or not the URL indicated in the url parameter should be opened.

- (UIImage) previewController(controller, transitionImageForPreviewItem:item, contentRect:contentRect)

Called when the Quick Look preview controller is about to be presented full screen or dismissed; used to provide a smooth transition when zooming. (required)

Parameters:

  • controller (QLPreviewController)

    The Quick Look preview controller that is requesting the frame for the preview item.

  • item (Object)

    The item to be previewed or dismissed.

  • contentRect (CGRect)

    The rectangle within the image that represents the document content. For icons, for example, the document content rectangle is typically smaller than the icon rectangle itself.

Returns:

  • (UIImage)

    A UIImage object that the preview controller crossfades with when zooming.

- (Object) previewControllerDidDismiss(controller)

Called after the preview controller is closed.

Parameters:

Returns:

- (Object) previewControllerWillDismiss(controller)

Called before the preview controller is closed.

Parameters:

  • controller (QLPreviewController)

    The Quick Look preview controller that is about to close.

Returns: