The next code snippet is an example of the question.
import SwiftUI
struct TestingView: View {
@State var myText = ""
@State var myText2 = ""
var body: some View {
NavigationStack {
Form {
Text("Row 1")
Text("Row 2")
TextField("Write here", text: $myText)
TextField("Write here too", text: $myText2)
}
.navigationTitle("Testing Toolbar") // delete if you want no title
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItemGroup(placement: .keyboard) {
Button {
print("Button up pressed")
} label: {
Image(systemName: "chevron.up")
}
Button {
print("Button down pressed")
} label: {
Image(systemName: "chevron.down")
}
Spacer()
}
}
}
}
}
struct TestingView_Previews: PreviewProvider {
static var previews: some View {
TestingView()
}
}
It works fine on iOS 16.4 or lower, but not on iOS 17. Any solution for iOS 17?
2
Answers
Found a workaround: adding an empty navigation path to the NavigationStack solved the issue for me (so far).
Credits to: https://stackoverflow.com/a/75756609/10603205
It works on iOS 17+ devices and 16.0+ devices & simulators, but not on iOS 17 simulator. This is certainly a bug.