51 questions
0
votes
0
answers
51
views
How to build a proxy as seen in ScrollViewReader and GeometryReader?
GeometryReader and ScrollViewReader use proxies but I don't know how they are constructed. Feels like a black box.
struct ContentView: View {
var body: some View {
GeometryReader { proxy ...
1
vote
1
answer
65
views
ScrollTo with ScrollViewReader doesn't work onAppear using Date as data
Hi Stack Overflow community, I have a problem. I want to create a date picker based on a ScrollView where the starting date is today, and the range is 15 days forward and backward. For some reason, ...
0
votes
1
answer
120
views
ScrollViewReader scrollTo not working in Form when .id() is used inside VStack
When using a Form and embedding the items in the form in VStacks, ScrollViewReader's scrollTo(...) is not working. Without the VStacks it does.
Is there a solution while keeping the VStacks?
Sample ...
0
votes
0
answers
83
views
SwiftUI ScrollViewReader does not scroll to last message when images are included
I am working on a SwiftUI chat application where I want the chat view to automatically scroll to the last message when the view appears and when new messages are added. The scrolling works fine for ...
0
votes
1
answer
693
views
SwiftUI: Chat like scrolling and keyboard behaviour
I am trying to build my own ChatGPT conversation app (SwiftUI with SwiftData, deployment target iOS 17.0) and am struggling a lot with the scrolling and keyboard behaviour in my ChatView. Basically I ...
0
votes
2
answers
97
views
Scroll results to top after button click
I have a View where I take input from the user. Once they click the Calculate button, I'll run a function to calculate the results and display the results below the Calculate button. What I would like ...
5
votes
1
answer
2k
views
iOS SwiftUI ScrollView in NavigationStack: Scroll To Top Doesn't Finish Expanding Navigation Title, If Animated
I'm needing to implement a scroll-to-top button for a ScrollView living in a NavigationStack, but when I call proxy.scrollTo() (with proxy being the ScrollViewProxy provided by ScrollViewReader), the ...
1
vote
0
answers
137
views
ScrollViewReader anchor y offset
I have a SwiftUI list view wrapped in ScrollViewReader. On change of date, I am using proxy.scrollTo(newDate, anchor: .top) to scroll to a section with corresponding date. I would ...
1
vote
0
answers
243
views
Can't correctly scroll to item when ScrollView ignores safe area
For some reason ScrollView should ignore safe area:
ScrollViewReader { proxy in
ScrollView {
...
...
}
.onChange(of: model.targetID) { id in
proxy.scrollTo(id, ...
2
votes
1
answer
242
views
@AppStorage var inside ScrollViewReader does not update view
I have an issue with @AppStorage and ScrollViewReader that seems like a bug.
My @AppStorage variable fontSize is supposed to adjust the text size inside a ScrollViewReader. However, when its value ...
1
vote
1
answer
445
views
Why is ScrollView changing content height to a random value on device but not on preview?
I am currently using **Xcode Version 14.3.1** (14E300c).
The scrollview in the code has an array of objects that I am iterating through with, ForEach(). When the user scrolls, lets say to object 30(...
1
vote
1
answer
974
views
How do I cause my List to scroll to show the last line in the backing Array of String using SwiftUI under macOS
I've tried several solutions that I've found but none work for me, mostly lengthy with compile errors that I didn't understand how to fix. I collaborated with an AI today and after the third ...
3
votes
1
answer
5k
views
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 ...
0
votes
0
answers
129
views
Why ScrollView with ScrollViewReader does not scroll with animation
I am using ScrollViewReader to slowly scroll images behind text. On my ScrollView I am using:
.onAppear {
withAnimation(.easeInOut) {
proxy.scrollTo(...
-1
votes
1
answer
398
views
ScrollViewReader won't scroll the View
I'm trying to scroll my lazyVStack using scrollViewReader. I've assigned the id to the child view i.e the ChatMessageView the id for the ChatMessageView is the index of my "messages" array ...
1
vote
0
answers
648
views
ScrollViewReader not scrolling to the correct id with anchor
Problem
First time when the button "Go to 990" is tapped the scroll view doesn't scroll to 990 on top. (see screenshot below)
The anchor is not respected.
Second time it scrolls to 990 top ...
3
votes
1
answer
3k
views
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 ...
0
votes
0
answers
295
views
SwiftUI - Animation not working for a subview inside parent scrollView
I have horizontal menu scrollView inside Parent vertical scrollView. When I select menu, it refresh it refreshes listView. But to fix parent scrollView content size, I need to refresh entire View (...
1
vote
0
answers
690
views
Scrolling inside a ScrollView in SwiftUI
In a giant ScrollView, I want to place Circles, and scroll to them so that, when scrolled, they end up in the middle of the screen, one after another.
I can position the Circles either by using ....
4
votes
0
answers
1k
views
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 ...
2
votes
1
answer
4k
views
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. ...
0
votes
1
answer
2k
views
Make ScrollViewReader scroll to item using a list and identifiable protocol in SwiftUI
I can't make ScrollViewReader to scroll on my List(). I have read many discussions such this or this
I use a model with Identifiable protocol and id as Int:
struct Country: Identifiable, Codable, ...
4
votes
1
answer
7k
views
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
...
9
votes
0
answers
708
views
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 ...
4
votes
2
answers
12k
views
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. ...