daspianist
daspianist

Reputation: 5525

How to automatically call PFQuery when scrolling down in a UICollectionView

I have an UICollectionView in which each cell contains a PFObject. As there are potentially hundreds of these objects for each UICollectionView, I don't want to query all the objects at once, and instead only call a limited amount, and then automatically call for more as the user scroll towards the end (somewhat like endless scrolling that many web apps use).

Would PFQuery support these type of calls, and if so how would I be able to call continuously and automatically?

Thanks!

Upvotes: 0

Views: 62

Answers (1)

Logan
Logan

Reputation: 53142

Perhaps something like this to get you on the right track:

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {

    float scrollViewHeight = scrollView.frame.size.height;
    float scrollContentSizeHeight = scrollView.contentSize.height;

    else if (scrollView.contentOffset.y <= 0) {
        // then we are at the top
    }
    else if (scrollView.contentOffset.y + scrollViewHeight >= scrollContentSizeHeight) {
        // then we are at the bottom - query new results


    }

}

I don't think you'd have to add anything for it to call as long as your controller is already your collectionView's delegate.

Upvotes: 1

Related Questions