4

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
  • 46,897
  • 22
  • 145
  • 209
Evan
  • 1,892
  • 2
  • 19
  • 40

0 Answers0