FZCarouselCollectionViewDelegate 提供了一个简单、轻量的接口来生成一个“无限”滚动的轮播图。
此类的使用者应首先从类中派生子类。子类应处理所有需要重写的 UICollectionViewDataSource、UICollectionViewDelegateFlowLayout 和 UICollectionViewDelegate 方法,以生成所需的 collectionView 布局。至少,预计用户将重写 -collectionView:cellForItemAtIndexPath: 方法,如果没有这样做将会抛出异常。
此类将处理所有“轮播图相关问题”,包括数据数组的操作和同步、页面控制更新以及当然,轮播图滚动。
self.carouselCollectionViewDelegate = [FZDemoCarouselCollectionViewDelegate carouselCollectionViewDelegateForCollectionView:self.collectionView dataArray:self.dataArray defaultCrankInterval:2.0f lazyCrankInterval:2.5f];
self.carouselCollectionViewDelegate.didSelectCellBlock =
^(UICollectionView *inCollectionView, NSIndexPath *inIndexPath, id inDataForIndexPath)
{
[tmpSelf showSelectionIndicator:YES withData:inDataForIndexPath];
};
[self.carouselCollectionViewDelegate beginCarousel];
[self.carouselCollectionViewDelegate endCarousel];