Class

UIDocumentBrowserViewController

A view controller for browsing and performing actions on documents stored locally and in the cloud.

Overview

With the document browser view controller, users can browse through and access their documents. By default, the document browser can access both the system’s local file provider and its iCloud file provider.

A screenshot of the document browser.

The local file provider grants access to all the documents in the app’s Documents directory. Users can also access documents from another app’s Documents directory, if that app declares either the UISupportsDocumentBrowser key, or both the UIFileSharingEnabled and LSSupportsOpeningDocumentsInPlace keys in its Info.plist file. When the user opens a document from another app's Documents directory, they're editing the document in place. The changes are saved to the other app's Documents directory.

The iCloud file provider creates a folder for your app in the user’s iCloud Drive. Users can access documents from this folder, or from anywhere in their iCloud Drive. The system automatically handles access to iCloud for you; you don't need to enable your app’s iCloud capabilities.

Third-party storage services can also provide access to the documents they manage by implementing a File Provider extension (iOS 11 or later). For more information, see FileProvider.

Topics

Creating a Document Browser

Adding a Document Browser to Your App

Give users access to their local or remote documents from within your app.

init(forOpeningFilesWithContentTypes: [String]?)

Initializes and returns a document browser view controller that can open the given file types.

Responding to Browser Events

protocol UIDocumentBrowserViewControllerDelegate

The protocol you implement to respond as the user interacts with the document browser.

Configuring a Document Browser

var allowedContentTypes: [String]

The document types that the browser can open.

var allowsDocumentCreation: Bool

A Boolean value that determines whether the document browser can create new documents.

var allowsPickingMultipleItems: Bool

A Boolean value that determines whether the user can select and open more than one document at a time.

func revealDocument(at: URL, importIfNeeded: Bool, completion: ((URL?, Error?) -> Void)? = nil)

Reveals (and optionally imports) the document at the provided URL.

Modifying the Browser's Appearance

enum UIDocumentBrowserViewController.BrowserUserInterfaceStyle

Styles that define the document browser's appearance.

var additionalLeadingNavigationBarButtonItems: [UIBarButtonItem]

Additional bar button items that the document browser displays on the leading side of its navigation bar.

var additionalTrailingNavigationBarButtonItems: [UIBarButtonItem]

Additional bar button items that the document browser displays on the trailing side of its navigation bar.

Adding Custom Actions

var customActions: [UIDocumentBrowserAction]

Custom document browser actions.

class UIDocumentBrowserAction

A custom action that you can create and add to a document browser's Edit Menu or navigation bar.

Animating Transitions

func transitionController(forDocumentURL: URL) -> UIDocumentBrowserTransitionController

Creates a transition controller that provides the standard system-loading and segue animations for the document browser.

class UIDocumentBrowserTransitionController

An object that implements the standard loading and transition animations for a document browser.

Errors

struct UIDocumentBrowserError

A structure that contains information about document browser errors.

enum UIDocumentBrowserError.Code

The error codes for errors raised by the document browser.

let UIDocumentBrowserErrorDomain: String

The error domain for errors raised by the document browser.

See Also

Document Browser

Adding a Document Browser to Your App

Give users access to their local or remote documents from within your app.

Building a Document Browser-Based App

Use a document browser to provide access to the user’s text files.

class UIDocumentPickerViewController

A view controller that provides access to documents or destinations outside your app’s sandbox.

Building an App Based on the Document Browser View Controller

Implement a custom document file format to manage user interactions with files on different cloud storage providers.