Whats the recommended way to programmatically scroll to particular content? #363
Unanswered
MadeByDouglas
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
So in UIKit with UITextView, we have scrollRangeToVisible which lets you scroll the text to a range of text. In SwiftUI what is the correct comparison? There is ScrollViewReader and the proxy, and recently there is now ScrollPosition, but as far as I can tell all of these assume you have a ForEach with several Text views, and you tag the text view, and scroll to that one.
How can we achieve something more like scrollRangeToVisible and just find a unique part of the text to scroll to? Can Markdown UI do this? What would be the recommended approach?
Looking at the demo, it seems this is an approach using the ScrollViewReader, but its not clear to me how it works or what its looking for. How can this be generalized to scroll to different markdown chapter headers for example? What does the OpenURLAction have to do with the scrolling fragment? Can proxy.scrollTo take any string and look for it? I thought its looking for an id tag of an object.
Beta Was this translation helpful? Give feedback.
All reactions