SwiftUI toolbar covered by keyboard accessory view
Asked Answered
J

0

6

Hi there I have a tricky problem to solve with SwiftUI in Xcode 12.4 (iOS 14): given I have a Form with numerous sections and TextEditors, this form having a .toolbar modifier (bottom bar) with some content (button in this case). All of it is wrapped within NavigationView. Once user clicks into one of the TextEditor, the bottom toolbar gets covered by keyboard's system accessory view. Note that I don't modify the safe areas at all. Anyone has an idea what is wrong with the code below?

struct ContentView: View {
    @State var narrative: String = ""

    var body: some View {
        NavigationView {
            Form {
                Section(header: Text("Test 1")) {
                    Text("Bla Bla Bla")
                }
                Section(header: Text("Test 2")) {
                    Text("Bla Bla Bla")
                }
                Section(header: Text("Test 3")) {
                    Text("Bla Bla Bla")
                }
                Section(header: Text("Test 4")) {
                    Text("Bla Bla Bla")
                }
                Section(header: Text("Test 5")) {
                    Text("Bla Bla Bla")
                }
                Section(header: Text("Text Editor 1")) {
                    TextEditor(text: $narrative)
                }
                Section(header: Text("Test 6")) {
                    Text("Bla Bla Bla")
                }
                Section(header: Text("Test 7")) {
                    Text("Bla Bla Bla")
                }
                Section(header: Text("Test 8")) {
                    Text("Bla Bla Bla")
                }
                Section(header: Text("Test 9")) {
                    Text("Bla Bla Bla")
                    TextEditor(text: $narrative)
                }
            }
            .navigationTitle("Title")
            .navigationBarTitleDisplayMode(.inline)
            .toolbar(content: {
                ToolbarItem(placement: .bottomBar) { Button("Press me") { }  }
            })
        }
        .navigationViewStyle(StackNavigationViewStyle())
    }
}

enter image description here

Japheth answered 9/8, 2021 at 14:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.