In our SwiftUI application , we are using List in one of our screen. We have a requirement to scroll to specific section header.
Below code works fine till iOS16 and from iOS16 onwards we are getting the app crash.
Can anyone suggest me any probable solution to achive this ?.
ScrollViewReader { proxy in
List {
ForEach(Array(viewModel.newSections), id: .self) { sectionName in
Section(header: VStack { LeaguesScheduleListSectionView(text: sectionName) }) {
ForEach(viewModel.newRowsPerSection[sectionName] ?? []) { leagueScheduleEvent in
LeaguesScheduleListRowView(leagueSchedule: leagueScheduleEvent)
}
}
.id(sectionName)
}
}
.listStyle(.plain)
.onAppear(perform: {
if viewModel.newSections.contains("Today/Ongoing"),
viewModel.newRowsPerSection[("Today/Ongoing")]?.count ?? 0 > 0 {
proxy.scrollTo("Today/Ongoing", anchor: UnitPoint.topLeading)
}
})
}