2

I want in a table view to load a certain amount of objects per page. Like what Instagram does. I've only seen how to do this in a PFQueryTableViewController using the line of code...

self.objectsPerPage = //Amount of objects per page

I am using Parse but I'm not using a PFQueryTableViewController. How would I accomplish the same thing the line of code above does?

John Doe
  • 1,609
  • 2
  • 13
  • 22
  • I was about to ask the same question. – suisied Nov 22 '15 at 05:08
  • I'm not sure how to load a limited amount of data in parse, but the way I do it is by loading 5 posts, and then loading more posts when the `scrollViewDidScroll(view: UIScrollView)` function is called, and `view.contentOffset.y + view.frame.size.height >= view.contentSize.height`. Essentially, this loads more posts whenever the user scrolls to the bottom of the view. – Jojodmo Nov 22 '15 at 06:58
  • did it solve the problem? have you tried downloading 100 post and storing it to an array and just controlling the objects to show everytime u scroll down? – suisied Nov 22 '15 at 09:58
  • @Jojodmo I understand how to do it but could you show me how to do it in code because I'm pretty new to Swift and not sure how I would do that. – John Doe Nov 22 '15 at 12:46
  • @JohnDoe Oh, in that case I'm not sure, because I'm not familiar with parse. – Jojodmo Nov 22 '15 at 17:41
  • @Jojodmo Ok no problem! Thanks for the help though. – John Doe Nov 22 '15 at 22:50

1 Answers1

1

Try approaching it this way

func scrollViewDidScroll(scrollView: UIScrollView) {
    if scrollView.contentSize.height - scrollView.contentOffset.y < (view.bounds.size.height) {
        if !isLoading() {
            loadNextPage()
        }
    }
}

loading the next objects when the tableview is within full screen, play around.

source : Detecting the bottom "bounce" of UITableView

Edit : you can use this pod as well

https://cocoapods.org/pods/UIScrollView-InfiniteScroll

Community
  • 1
  • 1
suisied
  • 426
  • 1
  • 6
  • 19