Adding custom actions and activities
Add custom document browser actions, activities, and bar items.
Overview
There are three different ways to add custom actions to the document browser:
Add document browser actions to the navigation bar or Edit Menu.
Add activities to the activity view.
Add bar items to the navigation bar.
Add document browser actions
By default, the system provides standard actions such as copy, move, rename, delete, and share. To add custom actions, assign an array of UIDocumentBrowserAction objects to the browser’s customActions property.
Document browser actions can be accessed in two ways:
Navigation bar actions appear in the navigation bar when someone places the browser in Select mode.
Edit Menu actions appear when someone long presses on a document or folder.
When someone initiates one of these actions, the actions receive the URLs of the currently selected items.
Add activities
The browser displays an activity view when someone taps the Share button (for example, when someone long presses on a document or folder and selects Share from the Edit Menu).
To add custom activities to the activity view, implement your UIDocumentBrowserViewControllerDelegate object’s documentBrowser(_:applicationActivitiesForDocumentURLs:) method and return an array of custom UIActivity objects.
Your delegate object receives an array of URLs for the currently selected items. You can store and use these URLs in your UIActivity subclass.
For design guidance, see Human Interface Guidelines > Collaboration and sharing.
Add bar button items
Use the additionalLeadingNavigationBarButtonItems and additionalTrailingNavigationBarButtonItems properties to add buttons to the navigation bar.
Actions that these buttons initiate don’t have access to the browser’s content or to the URLs of selected items. Use bar button items for actions that don’t affect a specific document or folder.