An error occurs when the Add button is pressed. On ios15 it worked fine.
On ios 15 it worked fine. but on ios16 An error occurs when the Add button is touched. I don't know why. Help.
Error: Thread 1: EXC_BREAKPOINT (code=1, subcode=0x1068e25ec)
public struct ListTest2: View
{
@State var data: [Int] = []
public var body: some View
{
ScrollViewReader
{ proxy in
VStack
{
Button {
proxy.scrollTo(data.count - 1)
} label: {
Text("goto end")
}
Button {
proxy.scrollTo(1)
} label: {
Text("goto start")
}
Button {
data.append(data.count + 1)
proxy.scrollTo(data.count - 1)
} label: {
Text("Add")
}
List {
ForEach(data, id:\.self)
{ index in
Text("\(index )")
}
}
}
.onAppear()
{
for index in 1...30 {
data.append(index)
}
}
}
}
}