1

I'm working on a project in SwiftUI and have a forEach loop, something like this:

ForEach(self.items, id: \.self) { item in
    Text(item)
        .padding(4)
}

and when I update self.items the ForEach view updates, but it also forces the scroll position back to the very top. Is there a way I could get the ForEach view to update and add the items without changing the current scroll position the user was at?

Any help with this matter would be appreciated. Also, I would prefer a non-iOS 14 method, since I'm working on an application to be released soon and don't expect it to be compatible with iOS 14.

pawello2222
  • 34,912
  • 15
  • 99
  • 151
Evan
  • 1,593
  • 2
  • 12
  • 27
  • Please add a [Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) – pawello2222 Jul 10 '20 at 00:07
  • 1
    Look at solution in [How to scroll List programmatically in SwiftUI?](https://stackoverflow.com/a/60855853/12299030), section for SwiftUI 1.0+. – Asperi Jul 10 '20 at 03:06

0 Answers0