Swift tableView Pagination

后端 未结 14 1243
长情又很酷
长情又很酷 2020-11-28 20:00

I have success working tableview with json parsing codes.But may have 1000 more item so need pagination when scrolling bottom side. I dont know how can i do this my codes un

14条回答
  •  有刺的猬
    2020-11-28 20:34

    Swift 5 (Full comprehensive pagination solution)

    The UI code: https://github.com/eonist/PaginationTable

    The Data Model code: https://github.com/eonist/PaginationService

    Core components:

    • rowData: This array will grow on each scroll-ended-event until it has loaded all items from backend-API
    • paginationAmount: The amount to fetch on each pagination cycle
    • paginationIndex: The current amount of cells (this grows as you load more data
    • isFetching: A boolean that lets the code know if data is already loading or not, to avoid double fetching etc fetchData: Simulates getting data from remote-api Gotchas:

    The example code is not reliant on a backend. It simply tests with data from a file and simulates network calls by sleeping for some seconds The example uses some dependencies in order to speed up the creation of this example. But its basic stuff like AFNetwork, Json parsing, Autollayout. All of which could easily be substituted Requirements:

    Backend-API that can provide the count of items Backend-API that can return items for a range (startIndex, endIndex)

提交回复
热议问题