Instance Property


A progress object that tracks a document as it loads.


var loadingProgress: Progress? { get set }


This property defaults to nil. If this property is set, the document browser modifies the document's thumbnail to show the loading progress.

Use this animation for documents that can take a noticeable amount of time to load.

To set up this animation:

  1. Get a transition controller for the document.

  2. Set a Progress object to track the document as it loads. Be sure to keep a strong reference to the transition controller until the animation is complete.

  3. Begin loading the document.

  4. When the load action is complete, present the document.

Listing 1 provides the loading animation when opening a document. Note that because UIDocument uses file coordination, the system may delay opening the file until it is available and ready to use. For example, the open(completionHandler:) method can trigger the download of a remote file, and the system won't call the completion handler until the download is complete.

Listing 1

Setting the loading animation

let doc = // Create a UIDocument subclass for the selected URL.
let editor = // Create a view controller to edit the document.
// Get the transition controller
let transitionController = controller.transitionController(forDocumentURL: url)
// Set the transition controller's progress
transitionController.loadingProgress = doc.loadProgress
// Keep a strong reference to the transition controller
doc.transitionController = transitionController
// Open the document { (success) in
    guard success else {
        // Handle the error here...
    // When the load is done, present the document
    controller.present(editor, animated: true, completion: nil)

See Also


var targetView: UIView?

The target view for transition animations when presenting or dismissing the transition controller's document.