Post

Replies

Boosts

Views

Created

LazyVGrid and ScrollViewReader
Is there a way to combine ScrollViewReader and LazyVGrid in order to scroll to a selected item? It looks like ScrollViewReader only works with ONE column designs like list. Ideally, something like this would be ideal, but does not work currently. ScrollViewReader { scroller in               LazyVGrid(columns: columns) {            ForEach(viewModel.tileArray, id: \.id) { thisTile in                   MyTileView(viewModel: thisTile)             }       } .onAppear { scroller.scrollTo(viewModel.selectedTileID, anchor: nil) } }
2
1
2.4k
Jun ’21
LazyVGrid and ScrollViewReader
Is there a way to combine ScrollViewReader and LazyVGrid in order to scroll to a selected item? It looks like ScrollViewReader only works with ONE column designs like list. Ideally, something like this would be ideal, but does not work currently. ScrollViewReader { scroller in               LazyVGrid(columns: columns) {            ForEach(viewModel.tileArray, id: \.id) { thisTile in                   MyTileView(viewModel: thisTile)             }       } .onAppear { scroller.scrollTo(viewModel.selectedTileID, anchor: nil) } }
Replies
2
Boosts
1
Views
2.4k
Activity
Jun ’21