0

I don't know how to make swiftUI know when I scroll to the end of a List. The key problem is, I can't use .onAppear() function in the element in List().

I tried to develop a ios app demo, using List() struct in the main view.I want to make the app know when I scroll to the end of the list and do something (like adding more content to the list). I tried to realized it by adding an element to the end of the List, and use .onAppear() function to modify that element. But I failed because of thread error- signal SIGABRT.

List {
        //some view
        Text(" ")
                    .onAppear() {
                        //do something
                }
                    .onDisappear() {
                        //do something
                }
}
  • 1
    Possible duplicate of [In SwiftUI, where are the control events, i.e. scrollViewDidScroll to detect the bottom of list data](https://stackoverflow.com/questions/56602089/in-swiftui-where-are-the-control-events-i-e-scrollviewdidscroll-to-detect-the) – Matteo Pacini Jun 19 '19 at 13:44
  • I was done with that question. The key point was't .onAppear. When I changed environmentObject in a list, it went wrong. So I change to @ State instead of @EnvironmentObject. – XINDUO CHEN Jun 20 '19 at 07:33

0 Answers0