My document-based app supports several different file types. It is currently written in SwiftUI using a UIDocumentBrowserViewController. I'm trying to convert to the new SwiftUI (v2) DocumentGroup paradigm. I need to let the user pick which kind of document to create when they tap the Create button in the document browser. Using DocumentGroup paradigm, I don't see how this is possible. When you create a DocumentGroup, you have to specify the document right there:
var body: some Scene {
DocumentGroup(newDocument: TextDocument()) { file in
TextDocumentEditor(document: file.$document)
}
}
When using UIKit, the browser calls a delegate function didRequestDocumentCreationWithHandler that lets the app inject some UI for picking a document type, before proceeding on. In fact, what you can do is provide the document browser with a template file to be used for creating the new doc. Is that possible in SwiftUI 2?
Post
Replies
Boosts
Views
Activity
Using the new SwiftUI support for FileDocument, is there a way to provide conflict resolution like there is for UIDocument? UIDocument provides documentState and stateChangedNotification. There is nothing defined in the FileDocument that indicates this capability. And SwiftUI does not seem to provide any automatic conflict resolution UI for your app. So when the user selects a document with conflicting versions, your app is unaware and simply opens the document for the user to edit.
Did UIFontPickerViewController stop working in the Simulator with Xcode 12 beta 3? I'm compiling for iOS 14/Swift, and when presenting UIFontPickerViewController, after a long pause, a blank view is displayed. Works using the iOS 13.5 Simulator, so it's only an issue with the iOS 14 Simulator. And Works OK on iOS 13 devices. I don't have an iOS 14 device to test.
A SwiftUI popover presented from a button installed in the nav bar via .toolbar(...) does not dismiss when tapped outside the popover. Instead, it jumps to the upper left corner of the screen.
This started happening in Xcode 12 beta 6. I've filed a bug with Apple (FB8546290).
.toolbar {
Button("Bad Popover") {
isShowingBadPopover.toggle()
}
.popover(isPresented: $isShowingBadPopover) {
Text("Tap outside and notice that the popover moves instead of being dismissed.")
.padding()
.frame(width: 320, height: 100)
}
}