swiftui - 出现键盘时,带有部分 Texteditor 的 SwiftUI 表单向上移动
问题描述
我有一个问题,在 Stack 上阅读了很多解决方案,但没有任何效果。我有一个包含不同部分、TextFields 和最后一个 Texteditor 的表单视图。当我单击文本编辑器时,表单中的编辑器应该在键盘上方。
我的代码:
var body: some View {
NavigationView{
VStack{
Form{
Section{TextField}
Section{TextField}
Section{
ZStack{
TextEditor
}
}
Section{
ZStack{
TextEditor(text: $info)
.ignoresSafeArea(.keyboard)
Text(info).opacity(0).padding(.all, 8)
}
}
}
.frame(alignment: .top)
.navigationBarItems(leading: Button(action: {
self.addUser = false
}, label: {
Image(systemName: "chevron.backward")
}))
}.onTapGesture {
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
}
}.navigationBarTitle("Kunden Hinzufügen", displayMode: .inline)
}
}
解决方案
推荐阅读
- solr - Solr 拼写检查 - 将正确的单词与建议的单词结合起来
- python - Pandas,字典列表,其中值是一个列表。将字典键转换为列名。将值列表中的每个元素转换为一行
- swiftui - 更新点击手势上的按钮文本
- python - Pylint:'无法导入'pathlib'(导入错误)'
- ios - 使用 Fastlane 发送 Codacy 代码覆盖率
- javascript - 404 无法使用 Express POST
- javascript - 我无法获取此 html 代码来显示我想要的内容
- javascript - 如何将数组中的特定图像调用为 Vanilla JavaScript 中的参数?
- spring-cloud-stream - SCDF Spring Cloud Stream 从 2.1.4 迁移到引导 2.2.4 版本中断了 kafka avro 流
- javascript - 何时在操作中使用调度与返回?