I am having bother getting a ToolbarItemGroup positioned on the backside of the display with .bottomBar placement in a FileDocument app.
Instance code under exhibits the problem. Situation seems on iOS 18.6.1 {hardware} and likewise iOS 18.5 simulator.
The toolbar is displayed with different placement values akin to .computerized.
Additionally, the toolbar is positioned accurately utilizing .bottomBar within the ContentView’s preview.
This difficulty is definitely simply the beginning of debugging a bigger mission that has the .bottomBar toolbar disappear (seemingly randomly) after a couple of minutes of the app working. Nevertheless, I doubt I can debug the bigger mission with out understanding the above difficulty.
Any recommendation?
import SwiftUI
import UniformTypeIdentifiers
@foremost
struct toolbar_debugApp: App {
var physique: some Scene {
DocumentGroup(newDocument: toolbar_debugDocument()) { file in
ContentView(doc: file.$doc)
}
}
}
struct ContentView: View {
@Binding var doc: toolbar_debugDocument
var physique: some View {
Textual content(doc.textual content)
.toolbar() {
ToolbarItemGroup(placement: .computerized) {
HStack{
Button("Open") { print("Open!")}
Spacer()
Button("Save") { print("Save!")}
}
}
}
}
}
extension UTType { static var exampleText: UTType { UTType(importedAs: "com.instance.plain-text") } }
struct toolbar_debugDocument: FileDocument {
var textual content: String
init(textual content: String = "Good day, world!") { self.textual content = textual content }
static var readableContentTypes: [UTType] { [.exampleText] }
init(configuration: ReadConfiguration) throws {
guard let information = configuration.file.regularFileContents,
let string = String(information: information, encoding: .utf8)
else {
throw CocoaError(.fileReadCorruptFile)
}
textual content = string
}
func fileWrapper(configuration: WriteConfiguration) throws -> FileWrapper {
let information = textual content.information(utilizing: .utf8)!
return .init(regularFileWithContents: information)
}
}