【发布时间】:2020-08-17 11:14:23
【问题描述】:
我有一个选择器:
Section(header: Text("About you")) {
TextField("About you", text: $profileViewModel.bio)
Picker(selection: $profileViewModel.education,
label: Text("Education Level")) {
ForEach(Education.levels, id: \.self) { level in
Text(level).tag(level)
}
}
TextField("Occupation", text: $profileViewModel.occupation)
}
当我单击文本字段时,会出现键盘,这很好,但是当我单击选择器时,它会将我带到新屏幕以选择值并返回到表单。这在我的模拟器(iPhone 11 Pro Max)上运行良好:
Version 11.6 (921.9.1)
SimulatorKit 581.9.1
CoreSimulator 704.12.2
但是,当我在我的真实设备 iPhone X - v13.5.1 上进行测试时,当我在文本字段(键盘可见)之后单击选择器时,应用程序崩溃了。我不确定这是一个错误?
然后我将 ontapGesture 放在选择器上以隐藏键盘:
Picker(selection: $profileViewModel.education,
label: Text("Education Level")) {
ForEach(Education.levels, id: \.self) { level in
Text(level).tag(level)
}
}.onTapGesture {
self.hideKeyboard()
}
这有时有效,但有时仍会崩溃,即使我将设备连接到 Xcode 并尝试获取日志,我也没有收到任何错误,应用程序只是冻结?
【问题讨论】:
-
值得向苹果提交反馈,而且看起来不像你的代码错误。
标签: swift swiftui uipickerview