Customize the document browser’s look and behavior.
You can set the browser’s appearance, create document thumbnails, and modify the browser’s behavior.
Set the Browser's Appearance
Change the browser's appearance by setting the
browser property. The document browser view controller supports white, light, and dark appearances.
Create Document Thumbnails or Icons
The system automatically provides thumbnails or icons for supported document types. If your app uses a custom or third-party document type, you can create a Thumbnail extension for that type. For more information, see
If you do not provide a Thumbnail extension, the system can create a document icon based on your app icon. To enable automatic icon creation, go to the Project navigator, choose the target, click Info, and then do the following:
Declare support for the document’s UTI in the Document Type section.
For any custom document types that you create, export the UTI in the Exported UTIs section.
For any third-party document types used by your app, import the UTI in the Imported UTIs section.
For more information, see Set the Supported Document Types.
Your app's icon only appears in the Files app or document browser when the following are all true:
The system doesn’t automatically provide a thumbnail for the UTI.
The system doesn’t already provide an icon for the UTI.
The user has not installed a Thumbnail extension for the UTI.
Your app both declares document type support for the UTI and declares the UTI as an exported or imported type.
Add Document Previews
The system automatically provides previews for supported document types. If your app uses a custom or third-party document type, you can create a Preview extension for that type.
For more information, see Quick Look.
Modify the Browser's Behavior
You can control the following behaviors:
The type of documents the browser opens.
Whether the browser opens multiple files at the same time.
Whether the browser creates new documents.
Set Allowed Document Types
You set the list of allowed document types when you create the browser. Pass an array of uniform type identifier (UTI) strings to the
init(for method. If you pass
nil, the browser uses the document types specified by the
CFBundle key in the app’s
For detailed instructions on setting the
CFBundle key, see Set the Supported Document Types).
The following example programatically creates a document browser for
Enable Multiple Document Selection
By default, users can select only one item at a time. To enable multiple document selection, set the document browser's
allows property to
Enable New Document Creation
To let users create new documents, you must do the following:
Set the browser's
true(the default value).
Browser View Controller Delegate
Browser(_: did Request Document Creation With Handler:)
After these steps are completed, the system automatically includes an Add button (+) in the document browser's navigation bar.
When the user taps the Add button, the system calls the
document method. In your implementation, you can present a custom user interface, where users can configure the document. For example, you might show a list of document templates.
Create a new document and save it to a temporary location. As soon as the document is saved, call the provided
import. To confirm the request, pass in the document's temporary URL and the import mode (
UIDocument). To cancel the request, pass