【发布时间】:2020-11-20 21:21:52
【问题描述】:
我在 iOS 14.2 中的 DatePickers() 视图中遇到问题,当键盘打开时它们在 Forms 中。 有人可以确认这是一个 swiftUI 错误吗?我是 iOS 开发新手。
这是我的看法:
struct TestView: View {
@State private var test = Date()
var body: some View {
return
NavigationView {
VStack {
HStack {
Spacer()
Capsule()
.fill(Color.secondary)
.frame(width: 80, height: 5, alignment: .center)
Spacer()
}.padding()
Form {
Section(header: Text("sectionTitle")) {
Group {
Text("something")
Text("To")
Text("Fill")
Text("The")
Text("View")
Text("Vertically")
Text("Bla")
Text("Bla")
Text("Bla")
Text("Bla")
}
Group {
Text("something")
Text("To")
Text("Fill")
Text("The")
Text("View")
Text("Vertically")
Text("Bla")
Text("Bla")
Text("Bla")
Text("Bla")
}
DatePicker("a label",
selection: $test,
displayedComponents: .hourAndMinute)
}
}
.padding()
}
}
}
}
正在发生的事情是: 当我单击 datePicker -> 选择器以模式显示时(iOS 14 中的正常行为),但在编辑它时,键盘会立即显示并消失,关闭模式。使 Picker 无法使用。
如果我删除表单视图或删除某些文本字段,则不会发生这种情况。
我在 iOS 14.2 iPhone SE 2020 模拟器和真实设备上的 sheet() 中使用此视图。 在ios13上正常工作(带轮子)。
谢谢
【问题讨论】: