I have this code:
struct MyPickerSelection: View {
@State private var picker1selection = 1
@State private var picker2selection = 1
@State private var showPicker1 = false
@State private var showPicker2 = false
var body: some View {
Form {
Section(header: Text("section 1")) {
HStack {
Text("selection \(picker1selection)")
Spacer()
Button(action: {
showPicker1.toggle()
}) {
Text("show picker 1")
}.foregroundColor(showPicker1 ? .red : .blue)
}
if showPicker1 {
Picker("choose", selection: $picker1selection) {
Text("value 0").tag(0)
Text("value 1").tag(1)
Text("value 2").tag(2)
Text("value 3").tag(3)
Text("value 4").tag(4)
}.pickerStyle(WheelPickerStyle()).compositingGroup().clipped(antialiased: true)
}
}
Section(header: Text("section 2")) {
HStack {
Text("selection \(picker2selection)")
Spacer()
Button(action: {
showPicker2.toggle()
}) {
Text("show picker 2")
}.foregroundColor(showPicker2 ? .red : .blue)
}
if showPicker2 {
Picker("choose", selection: $picker2selection) {
Text("value 0").tag(0)
Text("value 1").tag(1)
Text("value 2").tag(2)
Text("value 3").tag(3)
Text("value 4").tag(4)
}.pickerStyle(WheelPickerStyle()).compositingGroup().clipped(antialiased: true)
}
}
}
}
}
This can make a view where you can unfold two Picker to select values from 0 to 4, in my app this code is more complex but this reproduces the same error, when you try to select a value from the second Picker some times the app crashes for no reason, or vice versa, trying to select a value from Picker one makes the app crashes, or just unfold one or two Pickers and trying to scroll cause an app crash. This feel really random bug.
I'm not sure what's causing this behavior, in iOS 14 never happen, everything was fine, until today update to iOS 15.
The only error message i receive from Xcode is Thread 1: EXC_BAD_ACCESS (code=1, address=0x97157b0daa1403d8)
I think this is being caused by the use of two scrollable elements, but can't say if its true.
Any suggestion?