Questions tagged [scrollviewreader]
34 questions
8
votes
0 answers
SwiftUI ScrollViewReader preserve scroll position on resize
When using a ScrollViewReader to scroll to a certain position e.g. to 40% of the width - how can you preserve the scroll position when the content of the ScrollView resizes?
I wrote a small sample app to illustrate the problem:
Initially, the width…

Isaak
- 1,107
- 2
- 11
- 29
6
votes
2 answers
Implementing SwiftUI ScrollView snap-to-placement behavior (perhaps using a "scrollViewWillEndDragging" equivalent)?
There is a common way of handling scrolling with UICollectionView so that when the user stops scrolling it gradually slows down and stops with the nearest item in the collection view lined up with the edge of the collection view's bounds.
This…

Jeff C.
- 2,031
- 2
- 17
- 28
4
votes
0 answers
SwiftUI scroll to item after async load
I do async load of items from network .onAppear, after that my ViewModel force to redraw swiftUI view. After that i need scroll list to particular item. I do it .onRecieve, problem is that view redrawing and scrolling perform almost same time, but…

Mering
- 51
- 4
3
votes
1 answer
SwiftUI: animating scroll on ScrollView programmatically?
I need to programmatically animate the scroll of a scrollview. The scrollview contains either an HStack or a VStack. Code I tested with is this:
ScrollViewReader { proxy in
ScrollView(.horizontal, showsIndicators: false) {
…

zumzum
- 17,984
- 26
- 111
- 172
3
votes
2 answers
SwiftUI ScrollView Scroll to Relative Position
I have a big horizontal view that doesn't fit on screen, so I put it into a horizontal ScrollView.
If 0 would represent scrolled to the left completely and 1 to the right completely - How can I e.g. scroll to a relative position of 0.8?
Since I…

Isaak
- 1,107
- 2
- 11
- 29
3
votes
0 answers
SwiftUI Picker Does Not Scroll to Selection
I'm trying to use the SwiftUI 2 ScrollViewReader with a picker so that tapping on the
picker displays the picker list with the current selection in the view (preferably to an anchor). Nothing that I have tried, including the below, even has any…

JohnSF
- 3,736
- 3
- 36
- 72
2
votes
1 answer
ScrollViewReader, how to read the current row?
I'm looking for a tidy way to identify the current visible top row from a ScrollView. I would like the NavigationTitle to display the current row number.
Is there a way to do it with ScrollViewReader or must I do something with GeometryReader? In…

Bob
- 159
- 2
- 8
2
votes
2 answers
ScrollViewReader / scrollTo(_:anchor:) not working reliably
I've build a ScrollView which contains 0-3 images and a multiline text field in a VStack. I also added a ScrollViewReader inside the scrollview and use it to scroll to the bottom of the text field upon certain events (user starts typing, image…

Sebastian
- 335
- 2
- 10
2
votes
1 answer
LazyVStack in ScrollView has jittery auto scroll
I have a chat app, where whenever a chat room is opened, I need the view to scroll to the bottom as soon as the messages are fetched.
The thing is that although it does scroll perfectly when a new message is received or sent (see ViewModel down…

Sotiris Kaniras
- 520
- 1
- 12
- 30
2
votes
1 answer
SwiftUI ScrollViewReader scrollTo not working as expected
I am building a section of my app that allows users to train their skills in a sport by aiming for targets. Users can see their targets in a list. If more than 1 people are using this feature in my app, their training target lists are put next to…

Joris416
- 4,751
- 5
- 32
- 59
2
votes
0 answers
Can't Set SwiftUI ScrollViewReader Scrolling Animation Speed
In a SwiftUI app with SwiftUI flow for iOS15, I'm trying to slow the animation of the
ScrollViewReader scrolling speed. Clearly in the example below, the scrolling does
not take 100 seconds. While the animation in this example is visually ok, in the…

JohnSF
- 3,736
- 3
- 36
- 72
2
votes
1 answer
swiftui ScrollViewReader scrollTo not correct working
I am developing an application with swiftui. After zooming, when I say scroll to the corner with the ScrollViewReader, it goes out of the screen. my code is below. It fails after trying a few times. it doesn't do it every time.
import…

ursan526
- 485
- 3
- 10
2
votes
2 answers
How to get a horizontal ScrollView in SwiftUI to scroll automatically to end when the enclosed Text is updated
I am writing a SwiftUI iOS app where I need a Text view to automatically scroll to the end of its content whenever the content is updated. The update happens from the model. To not complicate this question with the details of my app, I have created…

Khawer K
- 105
- 1
- 6
2
votes
0 answers
ScrollViewReader anchor center creates free space
I want to zoom in on a specific element in the scrollview. I want it to be an anchor center. When zooming to the upper left elements, no problem, it works properly. But when you zoom in on the top right and bottom elements, space is created around…

ursan526
- 485
- 3
- 10
2
votes
0 answers
WatchOS ScrollReader Proxy Sluggish Scrolling
For WatchOS, I'm trying to build a ScrollView that auto scrolls to the last item added to a list. This all works fine, however once the ScrollView is full of content, the scrollTo func becomes very sluggish and slow. Setting the animation duration…

Jack
- 2,503
- 1
- 21
- 15