DocumentGroup
and UIDocumentBrowserViewController
similarly are both the entry point into your app. In macOS you have the menu bar where you can put document-independent functionality, but on iPadOS the only way I am aware of is to add buttons to the document browser's toolbar. Is there an equivalent to UIDocumentBrowserViewController
's additionalLeadingNavigationBarButtonItems
and additionalTrailingNavigationBarButtonItems
when using DocumentGroup?
For example, say you have a document-based app with a subscription and user account. In order to meet the account deletion requirement you can add an Account Settings button using additionalTrailingNavigationBarButtonItems
(and to the menu bar in macOS)...but where does this type of functionality belong when using DocumentGroup? Requiring a user to open or create a document before they can sign out or delete their account doesn't seem like the right solution, nor does it seem like it would meet the requirements to "Make the account deletion option easy to find in your app", so I hope I'm just missing something.
Also related, we use customActions
to allow users to save existing documents as templates. Is there a way to do this with DocumentGroup?
TIA!
In WWDC2024, the SwiftUI team introduces DocumentGroupLaunchScene, which allows you to customize the launch experience of a DocumentGroup
based app. I believe that is the API you are looking for. Fore more information, see:
When using DocumentGroupLaunchScene
, you can add your button(s) in the title view to present your own UI, as shown below:
DocumentGroupLaunchScene {
NewDocumentButton("New Document")
Button("Login") {
isLoginScreenPresented = true
}
.fullScreenCover(isPresented: $isLoginScreenPresented) {
Button("Dismiss") {
isLoginScreenPresented = false
}
}
}
When the title view has more than two buttons, SwiftUI displays the first one and a More...
button with an associated menu that shows the other buttons.
Note that putting a button in the overlay / background accessory view doesn't work – We intentionally make the accessory views un-interactive because of a security reason.
Best,
——
Ziqiao Chen
Worldwide Developer Relations.