I am having bother getting a ToolbarItemGroup positioned on the backside of the display with .bottomBar placement in a FileDocument app.
Instance code beneath exhibits the difficulty. Concern 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 appropriately utilizing .bottomBar within the ContentView’s preview.
This difficulty is definitely simply the beginning of debugging a bigger challenge that has the .bottomBar toolbar disappear (seemingly randomly) after a couple of minutes of the app operating. Nevertheless, I doubt I can debug the bigger challenge with out understanding the above difficulty.
Any recommendation?
import SwiftUI
import UniformTypeIdentifiers
@fundamental
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 = "Howdy, 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)
}
}