UIDocumentInteractionController — Open In and Documents

Author: IT Sectr Published: 2026-07-11 Reading time: 6 min

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 — an iOS controller for viewing and sending documents to other apps.
  • Preview — a built-in viewer for PDFs, images, and office documents without switching apps.
  • Open In — a file transfer function to another app for editing or viewing.
  • UIDocumentInteractionControllerDelegate manages animations, menu position, and operation completion.
  • Unlike UIDocumentPickerViewController, this API does not select files but transfers existing ones.

What is UIDocumentInteractionController?

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 Mode: Built-in Document Viewer

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 Mode: File Transfer Between Apps

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.

UIActivityViewController as an Alternative

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.

Code Example: Open In in Swift

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.

swift
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
        )
    }
}

Launching Preview Instead of Menu

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 and Lifecycle

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.

Differences from UIDocumentPickerViewController

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.

ParameterUIDocumentInteractionControllerUIDocumentPickerViewController
PurposeSend file to another appSelect file from another source
SourceOwn app fileAny storage (iCloud, Files, third-party)
ModeCopy of file to recipientImport or Export for current app
InterfaceSystem menu (Action Sheet)Full file browser
ReturnDoes not return a resultURL 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

What is UIDocumentInteractionController in iOS?

UIDocumentInteractionController is a UIKit controller for previewing documents and transferring files between apps via the Open In feature and built-in Preview.

How to open a file in another app using UIDocumentInteractionController?

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.

How is Preview different from Quick Look?

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.

Do I need to implement a delegate for UIDocumentInteractionController?

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.

How is UIDocumentInteractionController different from UIDocumentPickerViewController?

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

  • UIDocumentInteractionController — an iOS controller for viewing and sending files between apps, available since iOS 2.0.
  • Preview provides a built-in viewer for PDFs, images, and office documents without third-party libraries.
  • Open In copies the file to the selected app's sandbox — changes are not returned to the original app.
  • UIDocumentInteractionControllerDelegate manages animations, menu position, and send completion via delegate methods.
  • presentOptionsMenu displays a system menu with available apps for the given file type.
  • UIActivityViewController is a more modern alternative for file sharing since iOS 6.
  • Main difference from UIDocumentPickerViewController: the former sends a file from the app, the latter selects a file into the app.

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.

Discuss the project

Read also