UICollectionView を使っていて、最下部までスクロールした場合に
続きのコンテンツを読み込む処理を行う。
実装
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
ImageCollectionHeaderView *headerView = nil;
/*
中略
ここでヘッダーの生成を行う
*/
if ([kind isEqual:UICollectionElementKindSectionFooter])
{
// 最下部のセクションの場合
if (collectionView.numberOfSections == indexPath.section + 1) {
/*
続きを読む必要があるのか判定
NUMBER_OF_SECTIONS : 読み込むべき section の数、無制限ならこの if 文は不要
*/
if (NUMBER_OF_SECTIONS > indexPath.section) {
// 続きを読む関数
[self loadNextPage];
}
}
}
return headerView;
}
- (void)loadNextPage
{
// 続きを読む処理を行う
// この関数は複数回呼ばれるので、フラグを立てておいた方がいい
}