问题描述
我正在尝试在Swift UI中列出可选择行的列表,这些行包括Picker。一切正常,除了选择器的内容在选择时消失之外,请参见附件的屏幕截图(但在应用程序的窗口处于非活动状态(即,当我单击另一个窗口时)实际上是可见的)
我尽了所有可能的想法,无法解决此问题。下面用最少的代码重现该问题。任何人都有任何想法,如何解决这个问题
SelectionList.swift
struct SelectionList: View {
@State var dudes: [String] = ["Tim","Craig","Phil"]
@State var selectedRow = Set<String>()
var body: some View {
return List(selection: $selectedRow) {
ForEach(self.dudes,id: \.self) { item in
SelectionRow()
}
}
}
}
SelectionRow.swift
struct SelectionRow: View {
@State var selectedFruit = 0
let fruits = ["Apples","Oranges","Bananas","Pears"]
var body: some View {
Picker(selection: self.$selectedFruit,label: EmptyView()) {
ForEach(0 ..< fruits.count,id: \.self) {
Text(self.fruits[$0])
}
}
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)