UIKit Document App -- adding a toolbar

I've had to ditch the SwiftUI app lifecycle due to this issue: https://developer.apple.com/forums/thread/742580

After creating a new UIKit document app as a test, it doesn't have a toolbar when opening the document. How can I add one along the lines of https://developer.apple.com/wwdc22/10069 ?

The UIDocumentViewController isn't already embedded in a UINavigationController it seems.

To reproduce: New Project -> iOS -> Document App. Select Interface: Storyboard. Add an empty "untitled.txt" resource to the project. Change the first line in documentBrowser(_:,didRequestDocumentCreationWithHandler:) to

let newDocumentURL: URL? = Bundle.main.url(forResource: "untitled", withExtension: "txt")

I found the sample code for the WWDC video (https://developer.apple.com/documentation/uikit/app_and_environment/supporting_desktop-class_features_in_your_ipad_app), but having trouble figuring out which part actually creates the toolbar.

Ok seems I have to change presentDocument to:

    func presentDocument(at documentURL: URL) {

        let navVC = UINavigationController()

        let doc = Document(fileURL: documentURL)
        let docVC = UIDocumentViewController(document: doc)
        navVC.modalPresentationStyle = .fullScreen
        navVC.addChild(docVC)

        present(navVC, animated: true, completion: nil)
    }

So embed the UIDocumentViewController inside a UINavigationController.

UIKit Document App -- adding a toolbar
 
 
Q