I am trying to automatically get and load the next page of cells when the user scrolls to the bottom of the
- (UICollectionReuseableView *)collectionView: (UICollectionView *)collectionView viewForSupplementaryElementOfKind: (NSString *)kind atIndexPath: (NSIndexPath *) indexPath
// code for headerView
// code for footerView
MySupplementalFooter *footerView = nil;
if ( [kind isEqual:UICollectionElementKindSectionFooter] )
footerView = [self.collectionView dequeueReuseableSupplemntaryViewOfKind:kind withReuseIdentifier:@"FooterId" forIndexPath:indexPath];
[self loadMoreFooterButtonAction]; // calls the method to add cells to the dictionary for cv
I'm assuming that you're trying to do something like "infinite scrolling" from desktop webpages, where you load more content when a user gets to the bottom of a page. On iOS, this isn't a very commonly used design. Typically, developers will initialize their UITableView or UICollectionView with the absolute total number of entries. If they need to stream data over the network, they asynchronously load the data as needed (when cells or views come on screen) and until the content loads they show some kind of temporary content, like a blank view with a spinner.
That said, if you want to do infinite scrolling in a manner more like a desktop web app, you should implement the UIScrollViewDelegate protocol (or UICollectionViewDelegate, which is a superset) and listen for the scrollViewDidScroll: callback. Within that callback, iterate through the UICollectionView's indexPathsForVisibleItems and check to see if any of the index paths map to the 'last' item in your collection, which indicates the user has scrolled to the end. At that point, call your logic to load more stuff.