【发布时间】:2019-06-24 08:46:03
【问题描述】:
TextField 在 macOS 上的 List 中被禁用(不可编辑)。当为 iOS 构建相同的代码并在模拟器中运行时,它会按预期工作。
这是一个错误,还是我遗漏了什么?
代码:
struct ContentView : View {
@State private var text: String = ""
var body: some View {
VStack {
List {
// TextField is not editable when this code is ran on macOS
TextField($text, placeholder: Text("Entry text"))
Text("Entered text: \(text)")
}
// TextField is editable on both macOS as well as iOS
TextField($text, placeholder: Text("Entry text"))
}
}
}
【问题讨论】: