是否有机会做以下事情:
我有一个看法:
struct FirstView: View {
var body: some View {
ScrollView {
Text("Hello")
SecondView()
}
}
}
SecondView 包含一个 TextField:
struct SecondView: View {
@State private var text: String = ""
var body: some View {
ThirdView(text:$text)
}
}
struct ThirdView: View {
@Binding var text: String = ""
var body: some View {
TextField("Phone Number", text:$text)
}
}
当我尝试从 FirstView 打开 SecondView 键盘时,它不会这样做。但是当我在 ScrollView 中只添加一个 TextField 时,它就起作用了。
编辑:ThirdView 只是自定义 TextField