1
votes

My goal is basically to create a tableView with paging enabled that uses sections to determine the amount of pages, and which page you're on.

Example: 3 sections 1 section: 3 cells 2nd section: 14 cells - Scrolls to the very bottom of the section as a normal tableView would, when it hits the bottom, if you user continues swiping, goes to next page. 3rd section: 8 cells - Scrolls to bottom and stops.

So the first page would have 3 cells, then blank space, if you started to scroll up then the next section would appear, then that section header would snap to the top and you will have changed pages

The second page has many cells more than can fit on a single screen at one time, the user scrolls to the bottom of these, once the bottom is reached, can continue to scroll to reveal the third section header, then that header will snap to the top, etc

I know how to create a pages tableView, it is the paging out the tableview using sections rather than view height that I do not know is possible

1
I am facing the same issue..did you achieve this? - iSwaroop
@i_Looser unfortunately no. Haven't found a good solution - YichenBman

1 Answers

0
votes

I had to do something similar to your design.

I needed the first section to take up the entre screen and the second one to be an infinite scroll, with paging between Section 1 and Section 2 when scrolling down. Also, when scrolling up, I wanted the scroll to stop before the top section.

I know it is slightly different to your case, but you could quite easily figure out the height of each section and apply it similarly to my design.

here is how I did it :

func scrollViewDidScroll(scrollView: UIScrollView) {

    let offsetY = scrollView.contentOffset.y

    if (lastContentOffset > offsetY) {
        tableNode.view.pagingEnabled = offsetY < view.frame.height
    }

    lastContentOffset = offsetY
}


func scrollViewDidEndDecelerating(scrollView: UIScrollView) {

    let offsetY = scrollView.contentOffset.y
    tableNode.view.pagingEnabled = offsetY < view.frame.height

}

Note that the scrollViewDidEndDecelerating is important to re-enable paging when scrolling DOWN.

Also notice I am only setting the tableNode.view.pagingEnabled when the user scrolls UP in the scrollViewDidScroll function.

Hope this helps anyone looking for this in the future, as I hope for you @YichenBman you have come up with a solution by now.