I have a simple SwiftUI list that I want to scroll to a row when a user click on a button. This is my code that it suppose to work, but it does not do.
I tested it on iOS 14.2 both on simulator and a physical device.
I read srollTo's documentation) but there is not much info.
So how to scroll to a row, for example, row 50?
Code Block struct ContentView: View { var body: some View { ScrollViewReader { proxy in VStack { Button("Jump to #50") { proxy.scrollTo(5, anchor: .top) } List(0..<100) { i in Text("Example \(i)") .id(i) } } } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } }
I tested it on iOS 14.2 both on simulator and a physical device.
I read srollTo's documentation) but there is not much info.
So how to scroll to a row, for example, row 50?