我注意到,自从 iOS15 beta 5 以来,当我在一个列表中显示两个选择器并尝试从第二个列表中选择值时,我的应用程序崩溃了。在最新的 iOS14 中一切正常。崩溃时没有 StackTrace,应用程序只会在模拟器和真实设备上关闭。
有时这会出现在控制台中:=== AttributeGraph:通过属性 196632 检测到循环 ===
知道为什么吗?
查看以在最新的 Xcode 13 RC 中重现:
struct ContentView: View {
@State private var selected1 = 0
@State private var selected2 = 0
@State private var showPicker1 = false
@State private var showPicker2 = false
var body: some View {
NavigationView {
List {
HStack {
Text("Picker 1")
Spacer()
Text("\(selected1)").foregroundColor(.secondary)
}
.onTapGesture {
withAnimation {
self.showPicker1.toggle()
}
}
if showPicker1 {
Picker("", selection: $selected1) {
ForEach(1..<5) { idx in
Text("\(idx)").tag(idx)
}
}
.pickerStyle(.wheel)
.clipped()
}
HStack {
Text("Picker 2")
Spacer()
Text("\(selected2)").foregroundColor(.secondary)
}
.onTapGesture {
withAnimation {
self.showPicker2.toggle()
}
}
if showPicker2 {
Picker("", selection: $selected2) {
ForEach(1..<15) { idx in
Text("\(idx)").tag(idx)
}
}
.pickerStyle(.wheel)
.clipped()
}
}
.listStyle(.inset)
.navigationTitle("Picker")
}
}
}