UIDocumentInteractionController is an iOS controller for previewing documents and sharing files between apps. It implements the Open In feature, allowing users to open a file in any compatible app, send it by email, or save it to cloud storage. According to Apple Developer Documentation (2025), the controller also supports built-in Preview for viewing PDFs, images, and office documents.
Key Takeaways
UIDocumentInteractionController is a UIKit class that provides a system interface for working with documents. Unlike UIDocumentPickerViewController, which selects files, this controller works with an existing app file and offers the user actions: preview, open in another app, print, or send.
The controller is not a ViewController — it is not called via present. Instead, it displays a system action menu through the presentOptionsMenu or presentPreview method. The menu shows all apps registered to handle the given file type.
UIDocumentInteractionController has been available since iOS 2.0 and is one of the oldest APIs for working with documents. Despite its age, it remains relevant for implementing the Open In feature and built-in preview without third-party libraries.
Preview is a built-in document viewer provided by UIDocumentInteractionController. It supports PDFs, images, text files, and office documents (including .doc, .xls, .ppt). Preview displays with a transition animation similar to the standard Quick Look.
To launch Preview, call the presentPreview method. The controller requires a delegate that implements the previewControllerForDocumentInteractionController method, which returns a UIViewController for displaying the document. Typically, self or a navigation controller is returned.
Built-in Preview does not require additional frameworks or licenses. It works with any file whose URL is passed to the url property. Users can scroll through PDF pages, zoom images, and copy text from documents.
Open In is the key feature of UIDocumentInteractionController. It displays a list of apps that can open the given file type. The user selects a target app, and iOS copies the file to its sandbox, launching the app to work with the document.
The app list is generated automatically based on registered Document Type entries in other apps' Info.plist files. If an app registered PDF support, it will appear in the Open In menu for PDF files. The system also shows standard actions: print, send by email, save to Files.
Open In copies the file — the target app receives its own copy, so changes are not saved back to the original app. If you need editing with saving, use UIDocumentPickerViewController in export mode with a security-scoped URL.
Since iOS 6, UIActivityViewController has been available, which also supports file sharing. Unlike UIDocumentInteractionController, UIActivityViewController shows a system activity sheet with support for AirDrop, email, messages, and custom UIActivity. For simple file sharing, UIActivityViewController is recommended as a more modern API.
Implementation of Open In via UIDocumentInteractionController requires just a few lines of code: create an instance, set the URL and delegate, call presentOptionsMenu. The controller automatically collects the list of available apps based on the file type.
class DocumentViewController: UIViewController {
lazy var interactionController = UIDocumentInteractionController()
func shareFile(url: URL) {
interactionController.url = url
interactionController.uti = url.utiType()
interactionController.delegate = self
interactionController.presentOptionsMenu(
from: self.view.bounds,
in: self.view,
animated: true
)
}
}
To display the built-in viewer instead of the Open In menu, use the presentPreview method. The controller will show the document full-screen with scrolling capability. The delegate must implement the previewControllerForDocumentInteractionController method, returning a UIViewController for display.
UIDocumentInteractionControllerDelegate manages the display and dismissal of the menu and Preview. The delegate implements optional methods: documentInteractionControllerWillPresentOpenInMenu for appearance animation, documentInteractionControllerDidDismissOpenInMenu for resource cleanup after menu dismissal.
An important method for Preview is previewControllerForDocumentInteractionController, which must return a UIViewController for displaying the document. If the method is not implemented or returns nil, Preview will not launch. Typically, self or a UINavigationController containing self is returned.
The controller also supports the documentInteractionController:didEndSendingToApplication method, which is called after successfully sending the file to another app. This allows cleaning up temporary files or updating the interface after returning to the app.
UIDocumentInteractionController and UIDocumentPickerViewController solve different tasks, although both work with documents. The main difference: UIDocumentInteractionController transfers an existing file to another app, while UIDocumentPickerViewController selects a file from an external source for the current app.
| Parameter | UIDocumentInteractionController | UIDocumentPickerViewController |
|---|---|---|
| Purpose | Send file to another app | Select file from another source |
| Source | Own app file | Any storage (iCloud, Files, third-party) |
| Mode | Copy of file to recipient | Import or Export for current app |
| Interface | System menu (Action Sheet) | Full file browser |
| Return | Does not return a result | URL of selected file via delegate |
UIDocumentInteractionController does not require a delegate for basic operation — the menu will display even without implementing methods. UIDocumentPickerViewController without a delegate is useless — the selection result will not be processed. The API choice depends on the scenario: sending a file → UIDocumentInteractionController, receiving a file → UIDocumentPickerViewController.
Frequently Asked Questions
UIDocumentInteractionController is a UIKit controller for previewing documents and transferring files between apps via the Open In feature and built-in Preview.
Create an instance, set the url property to the target file, specify the delegate, and call presentOptionsMenu. The system will show a list of apps that support the given file type.
UIDocumentInteractionController Preview is a built-in viewer for a single document with basic capabilities. Quick Look (QLPreviewController) is a separate framework with support for batch viewing, extensions, and additional file formats.
The delegate is optional for basic operation — the menu will display without it. The delegate is mandatory only for Preview (the previewControllerForDocumentInteractionController method) and for tracking file send completion.
UIDocumentInteractionController sends an existing file from the app to another app. UIDocumentPickerViewController selects a file from an external source into the current app. The former is for sending, the latter for receiving.
Summary
We will develop a mobile application turnkey
IT Sectr creates iOS and Android applications for startups and businesses since 2017. We will advise you and propose the best solution.
Read also