skip to Main Content

I have a List in SwiftUI that I need to refresh but maintain current scroll position after refresh. I could do this in UITableView in UIKit but it seems impossible in SwiftUI. Am I missing something?

2

Answers


  1. It works if you have iOS 17 otherwise you should use ScrollView.

    Login or Signup to reply.
  2. Since you haven’t added code here, Please make sure you are following this thing in your code:

    1. do not create IDs on UI. Provide an Identifiable array using ViewModel.
    2. refresh array data on ViewModel.

    List will be refreshed once you refresh data. That is a main feature of SwiftUI. You don’t need to refresh like UITableView in UIKit. I suggest you to study more about SwiftUI.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search