SwiftUI分段选择器默认状态为nil

问题描述

我正在使用一种形式的分段选择器来回答简单的“是”和“否”问题。可以将分段选择器的初始状态设置为nil,以便在出现时不会突出显示/选择是或否吗?

@State private var equipmentCheck = 0
private var answers = ["Yes","No"]

var body: some View {
    NavigationView {
        Form {
            Section(header: Text("Questions")) {
                Text("Have the plant and equipment been checked?")
                Picker("",selection: $equipmentCheck) {
                    ForEach(0 ..< answers.count,id: \.self) {
                        Text("\(self.answers[$0])")
                    }
                }
                .pickerStyle(SegmentedPickerStyle())
                .padding()
            }
        }
    }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)