【发布时间】:2021-05-03 11:53:45
【问题描述】:
我有一个小问题,
我有一个带有选择器的 Swift 应用:
/// DATA.swift
import SwiftUI
class FormPage: ObservableObject {
@State var country = ["USA", "Japan", "Germany"]
@State var index = 0
}
/// FORM.swift
import SwiftUI
struct ContentView: View {
@StateObject var choiceForm = FormForFormulaire()
var body: some View {
Form {
Section {
Picker(selection: $choiceForm.index, label: Text("Pays de destination")) {
ForEach(0 ..< choice.country.count) {
Text(choiceForm.country[$0]).tag($0)
}
}
}
}
选择器视图正常,但没有更新:我点击日本,视图没有改变。
对不起我的英语,我希望有人能理解我!
谢谢
【问题讨论】: