Class: UIDocumentInteractionController

Inherits:
NSObject show all

Overview

A document interaction controller, along with a delegate object, provides in-app support for managing user interactions with files in the local system. For example, an email program might use this class to allow the user to preview attachments and open them in other apps. Use this class to present an appropriate user interface for previewing, opening, copying, or printing a specified file.

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from NSObject

#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version

Constructor Details

This class inherits a constructor from NSObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class NSObject

Instance Attribute Details

- (Object) annotation

Custom property list information for the target file. Use this property to pass information about the document type to the app responsible for opening it. The type of this object should be one used to contain property list information, namely NSDictionary, NSArray, NSData, NSString, NSNumber, or NSDate.

Returns:

- (Object) delegate

The delegate you want to receive document interaction notifications. You can implement a delegate object to track user interactions with menu items displayed by the document interaction controller. For more information, see UIDocumentInteractionControllerDelegate Protocol Reference. The default value of this property is nil.

Returns:

- (Array) gestureRecognizers (readonly)

The system-supplied gesture recognizers for presenting a document interaction controller. (read-only) The objects in the gestureRecognizers array each descend from the UIGestureRecognizer class. You can attach these gesture recognizers to the view you use to represent a document. For example, if you represent a document by name or icon in a table view cell , you can attach a document interaction controller’s gesture recognizers using code like this:(In this statement, the cell object is an instance of the UITableViewCell class and the docInteractionController instance variable points to the document interaction controller for the document named in the cell.)With gesture recognizers so attached, a user gesture automatically initiates the appropriate action. A tap gestures initiates a preview of the associated document. A long press gesture displays the options menu relevant to the document.The UIDocumentInteractionController class supports only the tap (UITapGestureRecognizer) and long press (UILongPressGestureRecognizer) gesture recognizers.

Returns:

- (Array) icons (readonly)

The images associated with the target file. (read-only) This property contains an array of UIImage objects containing the available icons for the given file. The images in the array are sorted from smallest to largest, with the smallest image located at index 0. The returned array always contains at least one image. The images themselves are provided by the system and determined by the UTI of the file. Apps can register custom icons for their associated files by including the appropriate meta information in their Info.plist file. If no custom icon exists, the images in this property represent the generic document icon.

Returns:

- (String) name

The name of the target file. This property contains the filename without any preceding path information. The default value of this property is derived from the path information in the URL property. You can change the value of this property as needed if you want to associate a different name with the file.

Returns:

- (NSURL) URL

The URL identifying the target file on the local filesystem.

Returns:

- (String) UTI

The type of the target file. The value of this property is used to determine which apps are capable of opening the document. The default value is determined automatically whenever possible. However, if the document is a custom type that cannot be determined readily, the value of this property may be nil. If you know the type of the document, you can set the value of this property explicitly.

Returns:

Class Method Details

+ (UIDocumentInteractionController) interactionControllerWithURL(url)

Creates and returns a new UIDocumentationInteractionController object initialized with the specified URL.

Parameters:

  • url (NSURL)

    A URL that specifies the location of the desired document. This parameter is retained. It can be changed later by modifying the URL property.

Returns:

Instance Method Details

- (Object) dismissMenuAnimated(animated)

Dismisses the currently active menu. Use this method to dismiss a menu programmatically. The document interaction controller can also dismiss the menu automatically in response to user actions.

Parameters:

  • animated (Boolean)

    Specify YES to animate the dismissal of the currently active menu or NO to dismiss it immediately.

Returns:

- (Object) dismissPreviewAnimated(animated)

Dismisses the currently active document preview. Use this method to dismiss the document preview programmatically. The document interaction controller may also dismiss the document preview automatically in response to user actions.

Parameters:

  • animated (Boolean)

    Specify YES to animate the dismissal of the document preview or NO to dismiss it immediately.

Returns:

- (Boolean) presentOpenInMenuFromBarButtonItem(item, animated:animated)

Displays a menu for opening the document and anchors that menu to the specified bar button item. This method is similar to the presentOptionsMenuFromBarButtonItem:animated: method, but presents a menu restricted to a list of apps capable of opening the current document. This determination is made based on the document type (as indicated by the UTI property) and on the document types supported by the installed apps. To support one or more document types, an app must register those types in its Info.plist file using the CFBundleDocumentTypes key.If there are no registered apps that support opening the document, the document interaction controller does not display a menu.This method displays the menu asynchronously. The document interaction controller dismisses the menu automatically when the user selects an appropriate app. You can also dismiss it programmatically using the dismissMenuAnimated: method.

Parameters:

  • item (UIBarButtonItem)

    The bar button item to which to anchor the menu.

  • animated (Boolean)

    Specify YES to animate the appearance of the menu or NO to display it immediately.

Returns:

  • (Boolean)

    YES if this method was able to display the menu or NO if it was not.

- (Boolean) presentOpenInMenuFromRect(rect, inView:view, animated:animated)

Displays a menu for opening the document and anchors that menu to the specified view. This method is similar to the presentOptionsMenuFromRect:inView:animated: method, but presents a menu restricted to a list of apps capable of opening the current document. This determination is made based on the document type (as indicated by the UTI property) and on the document types supported by the installed apps. To support one or more document types, an app must register those types in its Info.plist file using the CFBundleDocumentTypes key.If there are no registered apps that support opening the document, the document interaction controller does not display a menu.This method displays the options menu asynchronously. The document interaction controller dismisses the menu automatically when the user selects an appropriate option. You can also dismiss it programmatically using the dismissMenuAnimated: method.

Parameters:

  • rect (CGRect)

    The location (in the coordinate system of view) at which to anchor the menu.

  • view (UIView)

    The view from which to display the menu.

  • animated (Boolean)

    Specify YES to animate the appearance of the menu or NO to display it immediately.

Returns:

  • (Boolean)

    YES if this method was able to display the menu or NO if it was not.

- (Boolean) presentOptionsMenuFromBarButtonItem(item, animated:animated)

Displays an options menu and anchors it to the specified bar button item. The contents of the options menu are built dynamically based on three things:The type of the document (as specified by the UTI property)The set of installed apps that have registered support for opening documentsThe actions that you have indicated as supported in the document interaction controller delegate’s documentInteractionController:canPerformAction: methodOptions that cannot be performed on the current document are not included in the menu. For example, if the document cannot be opened by any known apps, the menu does not include options for opening it. This method displays the options menu asynchronously. The document interaction controller dismisses the menu automatically when the user selects an appropriate option. You can also dismiss it programmatically using the dismissMenuAnimated: method.To instead present a menu that contains only a list of apps capable of opening the current document, the presentOpenInMenuFromBarButtonItem:animated: method instead.

Parameters:

  • item (UIBarButtonItem)

    The bar button item to which to anchor the menu.

  • animated (Boolean)

    Specify YES to animate the appearance of the menu or NO to display it immediately.

Returns:

  • (Boolean)

    YES if the options menu was displayed or NO if it was not. The options menu may not be displayed in cases where there are no appropriate items to include in the menu.

- (Boolean) presentOptionsMenuFromRect(rect, inView:view, animated:animated)

Displays an options menu and anchors it to the specified location in the view. The contents of the options menu are built dynamically based on three things:The type of the document (as specified by the UTI property)The set of installed apps that have registered support for opening documentsThe actions that you have indicated as supported in the document interaction controller delegate’s documentInteractionController:canPerformAction: methodOptions that cannot be performed on the current document are not included in the menu. For example, if the document cannot be opened by any known apps, the menu does not include options for opening it.This method displays the options menu asynchronously. The menu is dismissed automatically when the user selects one of the available options. You can also dismiss it programmatically using the dismissMenuAnimated: method.To instead present a menu that contains only a list of apps capable of opening the current document, the presentOpenInMenuFromRect:inView:animated: method instead.

Parameters:

  • rect (CGRect)

    The location (in the coordinate system of view) at which to anchor the menu.

  • view (UIView)

    The view from which to display the options menu.

  • animated (Boolean)

    Specify YES to animate the appearance of the menu or NO to display it immediately.

Returns:

  • (Boolean)

    YES if the options menu was displayed or NO if it was not. The options menu may not be displayed in cases where there are no appropriate items to include in the menu.

- (Boolean) presentPreviewAnimated(animated)

Displays a full-screen preview of the target document. To use this method, you must first provide a delegate object that implements the documentInteractionControllerViewControllerForPreview: method. The view controller returned by that method is used to present the document preview modally.If your delegate implements the documentInteractionControllerViewForPreview: and documentInteractionControllerRectForPreview: methods, the view and rectangle returned by those methods is used as the starting point for the animation used to display the document preview. If the animated parameter is YES but your delegate does not implement the documentInteractionControllerViewForPreview: method (or that method returns nil), the document preview is animated into place using a crossfade transition. This method displays the document preview asynchronously. The document interaction controller dismisses the document preview automatically in response to appropriate user interactions. You can also dismiss the preview programmatically using the dismissPreviewAnimated: method.

Parameters:

  • animated (Boolean)

    Specify YES to animate the appearance of the document preview or NO to display it immediately.

Returns:

  • (Boolean)

    YES if this method was able to display the document preview or NO if it was not.