ppr*_*a72 6 ios swift swiftui swiftui-form swiftui-navigationview
您好,我在 Xcode 12.4 (iOS 14) 中使用 SwiftUI 需要解决一个棘手的问题:假设我有Form许多部分和TextEditors,此表单具有.toolbar带有一些内容(本例中为按钮)的修饰符(底部栏)。所有的一切都被包裹在里面NavigationView。一旦用户单击其中之一TextEditor,底部工具栏就会被键盘的系统附件视图覆盖。请注意,我根本不修改安全区域。任何人都知道下面的代码有什么问题吗?
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())
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
451 次 |
| 最近记录: |