下一个代码片段是问题的示例。
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()
}
}
它在 iOS 16.4 或更低版本上工作正常,但在 iOS 17 上不行。iOS 17 有什么解决方案吗?
不知道这是错误还是功能,但我遇到了同样的问题。到目前为止,我发现当我在模拟器上重新启动应用程序时,它解决了问题