iOS Developer Library — Pre-Release

Developer

UIKit Framework Reference UIDocumentMenuViewController Class Reference

Options
Deployment Target:

On This Page
Language:

UIDocumentMenuViewController

Inheritance


Conforms To


Import Statement


Swift

import UIKit

Objective-C

@import UIKit;

Availability


Available in iOS 8.0 and later.

A UIDocumentMenuViewController object represents a list of all the available document providers for a given file type and mode. You can also add your own custom menu items to this list.

  • Initializes and returns a document menu to import or open the given file types.

    Declaration

    Swift

    init!(documentTypes allowedUTIs: [AnyObject], inMode mode: UIDocumentPickerMode)

    Objective-C

    - (instancetype)initWithDocumentTypes:(NSArray *)allowedUTIs inMode:(UIDocumentPickerMode)mode

    Parameters

    allowedUTIs

    An array of uniform type identifiers. UTIs are strings that uniquely identify a file’s type. For more information, see Uniform Type Identifiers Overview.

    mode

    The type of file transfer operation the document picker performs. This argument accepts only the UIDocumentPickerModeImport or UIDocumentPickerModeOpen mode.

    Return Value

    Returns an initialized UIDocumentMenuViewController object, or nil if the object could not be successfully initialized.

    Discussion

    The UTI array defines the type of documents that can be imported or opened. The resulting document menu displays all the document pickers appropriate for the given document types and mode.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 8.0 and later.

  • init(URL:inMode:) - initWithURL:inMode: Designated Initializer

    Initializes and returns a document menu to export or move the given document.

    Declaration

    Swift

    init!(URL url: NSURL, inMode mode: UIDocumentPickerMode)

    Objective-C

    - (instancetype)initWithURL:(NSURL *)url inMode:(UIDocumentPickerMode)mode

    Parameters

    url

    The document to be exported or moved.

    mode

    The type of file-transfer operation that the document picker performs. This argument accepts only the UIDocumentPickerModeExportToService or UIDocumentPickerModeMoveToService mode.

    Return Value

    Returns an initialized UIDocumentMenuViewController object, or nil if the object could not be successfully initialized.

    Discussion

    The resulting document menu displays all the document pickers appropriate for the given mode.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 8.0 and later.

  • Adds a custom menu item to the list of document pickers.

    Declaration

    Swift

    func addOptionWithTitle(_ title: String?, image image: UIImage?, order order: UIDocumentMenuOrder, handler handler: (() -> Void)!)

    Objective-C

    - (void)addOptionWithTitle:(NSString *)title image:(UIImage *)image order:(UIDocumentMenuOrder)order handler:(void (^)(void))handler

    Parameters

    title

    The custom menu item’s title.

    image

    The custom menu item’s image.

    order

    The position of this menu item. See UIDocumentMenuOrder for possible values.

    handler

    A block that is called when the user selects this custom menu item.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 8.0 and later.

  • delegate delegate Property

    The document menu’s delegate.

    Declaration

    Swift

    weak var delegate: UIDocumentMenuDelegate?

    Objective-C

    @property(nonatomic, weak) id< UIDocumentMenuDelegate > delegate

    Discussion

    The delegate must adopt the UIDocumentMenuDelegate protocol.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 8.0 and later.

  • The insertion point for custom menu items.

    Declaration

    Swift

    enum UIDocumentMenuOrder : UInt { case First case Last }

    Objective-C

    typedef NS_ENUM (NSUInteger, UIDocumentMenuOrder ) { UIDocumentMenuOrderFirst, UIDocumentMenuOrderLast }

    Constants

    • First

      UIDocumentMenuOrderFirst

      The top item in the document menu.

      Available in iOS 8.0 and later.

    • Last

      UIDocumentMenuOrderLast

      The bottom item in the document menu.

      Available in iOS 8.0 and later.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 8.0 and later.